bool  CRBase::SetData(ULONG nCol, void *pSrcData, ULONG nSrcLen=OLEDB_STRING_END);

Return Value

        true if successful; otherwise false.

Parameters   

        [in] nCol:

                A column ordinal.

        [in] pSrcData:

                A pointer to a data.

        [in] nSrcLen:

                The length of the buffer pSrcData in bytes. For a fixed-length type data, it is ignored. However, it is required when a string data is not null-terminated or the data type of the column nCol is DBTYPE_IUNKNOWN, DBTYPE_BYTES or DBTYPE_VARNUMERIC.

Remark

        Sends a data into a provider with use of an internal writing accessor. It can be also used to send a BLOB data as an in-memory data or a storage object into a data source. Here is the example to use it for special data types.

        CBulkRecord<COTable<CRBase> >      BulkRecord;
        BSTR                                   bstrEmpName=NULL;
        VARIANT                           vtAddress;
        ISequentialStream                 *pISequentialStream=NULL;
        ULONG                                nLenOfStream=0;

        //Suppose that columns 4, 5, 6 have a name, an address and photo, respectively for an employee, and BulkRecord is opened and moved to a record.
        //Suppose that columns 4, 5, 6 are already set with data types, DBTYPE_BSTR, DBTYPE_VARIANT and DBTYPE_IUNKNOWN, respectively.


        //Suppose that bstrEmpName, vtAddress, pISequentialStream and nLenOfStream are already set properly.

        BulkRecord.SetData(4, &bstrEmpName);  
        BulkRecord.SetData(5, &vtAddress);
        BulkRecord.SetData(6, &pISequentialStream, &nLenOfStream); 

        //Attention: provider releases a client created stream object after this call!
       
BulkRecord.Update();                    

        //must free the client allocated memories somewhere after these calls

        if(bstrEmpName) SysFreeString(bstrEmpName);
        VariantClear(&vtAddress);

        This function is similar with CRBase::SetDataEx, but there are differences between the two. The former uses an internal writing accessor and is efficient for updating a data, but the later uses a temporary accessor with better flexibility and is somewhat less efficient because it needs to create a temporary accessor and release it after call.

CRBase Class Overview & Class Members