0x800a0cb3 when Update record



Hello,

I'm using VC++ 2005 and ADO to connect to an MS SQL 2000 server database.
When I try to update a value I get 0x800a0cb3 as a result :-(
The user I am logging as owns the database.

My code:

g_dataSource is a CString that contains the connection string, which looks
like this:
Provider=SQLOLEDB.1;Password=xxxx;Persist Security Info=True;User
ID=test1;Initial Catalog=skyltdata;Data Source=AME1\MESQL;Extended
Properties="ByteaAsLongVarBinary=1;"

_ConnectionPtr pConnection;
_RecordsetPtr pRec;

HRESULT hr = pConnection.CreateInstance(__uuidof(Connection));
if(FAILED(hr)) return false;

hr = pConnection->Open((_bstr_t)g_dataSource,L"", L"", -1);

if(FAILED(hr)) return false;

pConnection->BeginTrans();


hr = pRec.CreateInstance((__uuidof(Recordset)));
if(FAILED(hr)) return false;

pRec->CursorLocation = adUseServer;

_variant_t vVar;
hr = pRec->Open(_bstr_t(sql), pConnection.GetInterfacePtr(), adOpenDynamic,
adLockPessimistic, adCmdUnknown);
if(FAILED(hr)) return false;

vVar.vt = VT_I4;
vVar.lVal = 1L;
pRec->Fields->Item[_T("Producerad")]->Value = vVar; // Error
pRec->Update(NULL, NULL);
pConnection->CommitTrans();
pRec->Close();
pRec = NULL;
pConnection->Close();
pConnection = NULL;


Anyone that can give me a hint on why I get this error?

// Anders
--
English is not my first, or second, language
so anything strange, or insulting, is due to
the translation.
Please correct me so I may improve my English!
.


Loading