Hi, I am trying to use IRowsetFastLoad to insert multiple columns to a permanent SQL Server table.. The problem is, that the InsertRow returns an E_FAIL, which is a provider specific error. I am staging the column Data as follows into the memory buffer: (with Appropriate offsets for the bindings & the Accessor)
Here's how i stage my column data:
dbBinding[0].dwPart = DBPART_VALUE | DBPART_LENGTH | DBPART_STATUS;
dbBinding[0].iOrdinal = 1;
dbBinding[0].pTypeInfo = NULL;
dbBinding[0].obValue = ulOffset + offsetof(COLUMNDATA, bData);
dbBinding[0].obLength = ulOffset + offsetof(COLUMNDATA, dwLength);
dbBinding[0].obStatus = ulOffset + offsetof(COLUMNDATA, dwStatus);
dbBinding[0].cbMaxLen = 30; //Size of varchar column.
dbBinding[0].pObject = NULL;
dbBinding[0].pBindExt = NULL;
dbBinding[0].dwFlags = 0;
dbBinding[0].eParamIO = DBPARAMIO_NOTPARAM;
dbBinding[0].dwMemOwner = DBMEMOWNER_CLIENTOWNED;
dbBinding[0].bPrecision = 0;
dbBinding[0].bScale = 0;
dbBinding[0].wType = DBTYPE_STR;
uTemp = dbBinding[0].cbMaxLen + offsetof(COLUMNDATA, bData);
uTemp = ROUND_UP( uTemp, COLUMN_ALIGNVAL );
//ulOffset += offsetof(COLUMNDATA, bData);
ulOffset += uTemp;
dbBinding[1].dwPart = DBPART_VALUE | DBPART_LENGTH | DBPART_STATUS;
dbBinding[1].iOrdinal = 2;
dbBinding[1].pTypeInfo = NULL;
dbBinding[1].obValue = ulOffset + offsetof(COLUMNDATA,bData);
dbBinding[1].obLength = ulOffset + offsetof(COLUMNDATA,dwLength);
dbBinding[1].obStatus = ulOffset + offsetof(COLUMNDATA,dwStatus);
dbBinding[1].cbMaxLen = 30; //Size of varchar column.
dbBinding[1].pObject = NULL;
dbBinding[1].pBindExt = NULL;
dbBinding[1].dwFlags = 0;
dbBinding[1].eParamIO = DBPARAMIO_NOTPARAM;
dbBinding[1].dwMemOwner = DBMEMOWNER_CLIENTOWNED;
dbBinding[1].bPrecision = 0;
dbBinding[1].bScale = 0;
dbBinding[1].wType = DBTYPE_VARIANT;
This is the call for creating the accessor:
if(FAILED(hr = pIAccessor->CreateAccessor(DBACCESSOR_ROWDATA, 2, dbBinding, ulOffset, &hAccessor, dbStatus)))
return hr;
The dbStatus returned for both bindings is S_OK
And here is how it is copied to the in-memory buffer:
memcpy(&(pcolData->bData), _com_util::ConvertBSTRToString(strOutput), strOutput.length() + 1);
memcpy(&((pcolData+dbBinding[0].obValue)->bData), _com_util::ConvertBSTRToString(strOutput), strOutput.length() + 1);
[B] if(FAILED(hr = pIFastLoad->InsertRow(hAccessor, pData)))[/B]
............
The returned code for the insert row is E_FAIL
Any ideas what I might be doing wrong here? Surprisingly, I can't seem to find anything on the internet that explains how to do this...