problem in ADO with Microsoft Jet 4.0 OLE DB

problem in ADO with Microsoft Jet 4.0 OLE DB

Post by Behza » Fri, 05 Nov 2004 17:01:51


hi,
I am using ADO to connect an acess database. When I modify an integer field
and use Update to update it , it throws an unhandled exception. Is there a
problem in ADO with access. I have had no problem in using SQL server.

I use some code like this:
LONG l1=0x0ff;

OperatorsDB.m_pRs->Fields->GetItem(_T("AccessRights"))->Value=l1;

OperatorsDB.OnUpdate();

thanks,
Behzad
 
 
 

problem in ADO with Microsoft Jet 4.0 OLE DB

Post by Anders Eri » Fri, 05 Nov 2004 22:21:08


Just guessing, since the field is an integer and you are trying to fill it
with an LONG, you will then get some kind of error....

What happens if you put the code within try/catch
and/or change the LONG to int / change the field to Long Integer.


The code looks OK!

// Anders

 
 
 

problem in ADO with Microsoft Jet 4.0 OLE DB

Post by Bill Thomp » Sat, 06 Nov 2004 06:30:32


field

this code works for me...

long FieldValue = 5;
try
{
_variant_t vtValue(FieldValue);
// this assignment fixes a 'bug' where first chance exception
// messages are issued while in debug mode (VC 6.0)
// the old code was:
// FieldPtr pField = Rst.Fields->GetItem(FieldName)->Value;
// note that if you step through the code, the exception was not
issued
FieldPtr pField = Rst.Fields->GetItem(FieldName);
pField->PutValue(vtValue);
}