question

Jahnavi S avatar image
Jahnavi S asked

IDispatch Error #3105 while updating a field value

Hi All,

Below is the snippet of my code:

void CNvlsMwbi::WriteToDB() { _variant_t vTmp ; FieldsPtr pFields ; FieldPtr pField ; _variant_t vConn ; HRESULT hr; CString csTemp ; _RecordsetPtr pRecset ;

// Create Recordset object                    
hr = pRecset.CreateInstance("ADODB.Recordset") ;                    
                    
if FAILED(hr)                    
    log (0, " Failed to create Recordset - ( CNvlsMwbi::WriteToDB() )\n") ;                    
                    
                    
if(m_pConnection)                    
{                    
    try                    
    {                    
        vConn = (IDispatch *)m_pConnection ;                    
        // Opens Recordset corresponding to NVLS MWBI table.                    
                    
        hr = pRecset->Open(TBL_NVLSMWBI, vConn, adOpenStatic, adLockOptimistic, adCmdTable) ;                    
        // Adds a new record into the recordset                    
        hr = pRecset->AddNew() ;                    
        pFields = pRecset->Fields ;                    
                // Updating all the values in to the recordset                    
                    
        CDBUtils::UpdateLongField(pFields, "MWBFDataID", m_nMWBFDataID);                    
        CDBUtils::UpdateLongField(pFields, "Mode", m_nNrtStd) ;                         
                    
        // Updating the values into the database                    
        hr = pRecset->Update() ;                    
        pRecset->Close() ;                          
    }                    
    catch( _com_error &e )                    
    {                    
        log(0,"'%s\' - (CNvlsMwbi::WriteToDB)\n", (char*) e.ErrorMessage());                    
        log(0,"'%s\' - (CNvlsMwbi::WriteToDB)\n", (char*) e.Description());                    
    }                    
}                    
else                    
    log(0, "Connection String is NULL - ( CNvlsMwbi::WriteToDB() )\n") ;                    

}

while executing the step

CDBUtils::UpdateLongField(pFields, "MWBFDataID", m_nMWBFDataID);

I get an exception as IDispatch error #3105 "Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done."

DBUtils::UpdateLongFields does as follow : { CString csTemp ; FieldPtr pField ; long lTempValue ;

lTempValue = lValue ;                    
                    
// if the value to be stored in long field is (-1), i.e., empty,  then we should first check,                    
// if the field allows NULL.  If it allows null,  we dont have to store anything into the field variable,                    
// as by default it will take NULL.   If Null is not allowed, then we will store some default value, as ZERO (0).                    
// NOTE:  Here,  Planning to store ZERO (0).  THIS CARE HAS BEEN TAKEN TO AVOID DATABASE EXCEPTIONS.                    
if (lValue == -1)                    
{                    
    if (! bIsNullAllowed )                     
        lTempValue = 0;                    
    else                    
        return ;                    
}                    
else                    
{                    
    lTempValue = lValue ;                    
}                    
                    
pField = pFields->Item[_variant_t(csFieldName)] ;                    
csTemp.Format("%i", lTempValue) ;                    
pField->Value = csTemp.GetBuffer(csTemp.GetLength() + 1) ;                     

}

in step pField->Value = csTemp.GetBuffer(csTemp.GetLength() + 1) ; the put_value of COM returns -2147217887 (HEX 80040E21).

Please let me know what is the problem happening while adding a value into the table.

Thanks, Jahnavi

sql-server-2000queryinsert
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

0 Answers

· Write an Answer

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.