HI Guys,

I use ole db to operate database, when I insert 4 records in one statement, if one record failed, How to get its offset? for example, if the second record failed, how to know the failed record is the second record ?

My code show below:
Code:
    CComPtr<IDBCreateSession>	pIDBCreateSession;
    CComPtr<IDBCreateCommand>	pIDBCreateCommand;
    CComPtr<ICommandText>	pICommandText;
    CComPtr<ICommandPrepare>	pICommandPrepare;
    CComPtr<IAccessor>	              pIAccessor;
    HACCESSOR hParamAccessor=DB_NULL_HACCESSOR;
    DBPARAMS Params={0};
    LPSTR pRowValues=NULL;

   // map binding type
   MapBindingType(...);

   if(FAILED(hResult=_pIDBInitialize->QueryInterface(IID_IDBCreateSession,(void**)&pIDBCreateSession));
    if(FAILED(hResult=pIDBCreateSession->CreateSession(NULL,IID_IDBCreateCommand,(IUnknown**)&pIDBCreateCommand)));

    if(FAILED(hResult=pIDBCreateCommand->CreateCommand(NULL,IID_ICommandText,(IUnknown**)&pICommandText)));
    if(FAILED(hResult=pICommandText->SetCommandText(DBGUID_DBSQL,CONVERT_CHAR(sqlString._sqlBuffer))));

   if(FAILED(hResult=pICommandText->QueryInterface(IID_ICommandPrepare,(void**)&pICommandPrepare)))
   if(FAILED(hResult=pICommandPrepare->Prepare(max(64*1024,min(1024*1024*40L,pDBRds->numRecords*cbRow)))));

   if(FAILED(hResult=pICommandText->QueryInterface(IID_IAccessor,(void**)&pIAccessor)));

    if(FAILED(hResult=pIAccessor->CreateAccessor(DBACCESSOR_PARAMETERDATA,pDBRds->numFields,_oleDBBinding,cbRow,&hParamAccessor,NULL)))

    long typeTransaction(0);

    CComPtr<ITransactionLocal> pITransactionLocal;
    if(SUCCEEDED(pIDBCreateCommand->QueryInterface(IID_ITransactionLocal,(void**)&pITransactionLocal)));

if(SUCCEEDED(pITransactionLocal->StartTransaction(ISOLATIONLEVEL_REPEATABLEREAD,0,NULL,NULL))) 
typeTransaction = 2;

Params.pData = pRowValues;
Params.cParamSets = __oledb_maxbatch__;
Params.hAccessor = hParamAccessor;

// map binding data
MapOledbData(...);

if(SUCCEEDED(hResult=pCommand->Execute(NULL,IID_NULL,pParams,&cRowsAffected,NULL)));

pITransactionLocal->Commit(FALSE,0,0);

if(cRowsAffected != __oledb_maxbatch__)
{
// How to get offsest of the error records?}