bool CRBase::GetDataEx(ULONG nCol, void *pBuffer, DBTYPE nDBType, ULONG nSize=0, BYTE nPrecision=0, BYTE nScale=0);

Return Value

        true if successful; otherwise false.

Parameters

        [in] nCol:

                A column ordinal.

        [in] pBuffer:

                A pointer to a client allocated memory.

        [in] nDBType:

                A data type indicator.

        [in] nSize:

                The length of the buffer pBuffer in bytes. For a fixed-length type data, it is ignored. However, it is required for a variable-length type data.

        [in] nPrecision:

                The maximum precision to use when nDBType is DBTYPE_NUMERIC or DBTYPE_VARNUMERIC only.

        [in] nScale:

                The scale to use when nDBType is DBTYPE_NUMERIC, DBTYPE_VARNUMERIC, or DBTYPE_DECIMAL only.

Remark

        Gets a data by creating a temporary accessor no matter if the column is discarded. This function is designed for retrieving various data in different formats with great flexibility. It can be also used to retrieve a BLOB data as an in-memory data or a storage object. It is notified that a caller must pay a special attention to memory leaking and free the provider allocated memory properly when nDBType is one of special data types. Here is the example to free the provider allocated memory.

        CBulkRecord<CRBase>      BulkRecord;
        BSTR                                   bstrEmpName=NULL;
        VARIANT                           vtAddress;
        ISequentialStream                 *pISequentialStream=NULL;

        //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.

        BulkRecord.GetDataEx(4, &bstrEmpName, DBTYPE_BSTR);   //provider allocated a memory holding the name
        VariantInit(&vtAddress);
        BulkRecord.GetDataEx(5, &vtAddress, DBTYPE_VARIANT); //provider allocated a memory holding the address
        BulkRecord.GetDataEx(6, &pISequentialStream, DBTYPE_IUNKNOWN); //provider created a stream object

        //a caller must free the provider allocated memories somewhere after processing obtained data

        if(bstrEmpName) SysFreeString(bstrEmpName);
        VariantClear(&vtAddress);
        if(pISequentialStream) pISequentialStream->Release();

CRBase Class Overview & Class Members