CRecordset - access violations 
Author Message
 CRecordset - access violations

I have an CRecordset (MFC 4.2) that contains a date column.   After adding
the first new record, but before returning from rs.Update(), I get an access
violation in the RFX_Date() / DoFieldExchange() functions.   I've traced
through this and discovered it happens during the CrecordSet:::LoadData()
call.   I tried wrapping this with TRY/CATCH but to no avail.   Needless to
say, the program terminates, leaving any further data unposted.

If I crank up Access and look at the table, it's fine.  I've noticed that
DoFieldExchange is called 3 times during AddNew and 4 times on Update() -
it's this 4th time that hoses my program.

Now before someone says, use CDaoRecordset, let me tell you why not.  These
record sets are common code that 's used for multiple db sources (Access and
SQL Server) and I'd rather not incur the overhead of DAO when using SQL
Server.  I'm not sure that DAO would solve it anyway.

Anyone else encountered this problem?

Thanks
Chuck



Wed, 23 May 2001 03:00:00 GMT  
 CRecordset - access violations

Quote:

> I have an CRecordset (MFC 4.2) that contains a date column.   After adding
> the first new record, but before returning from rs.Update(), I get an access
> violation in the RFX_Date() / DoFieldExchange() functions.   I've traced
> through this and discovered it happens during the CrecordSet:::LoadData()
> call.   I tried wrapping this with TRY/CATCH but to no avail.   Needless to
> say, the program terminates, leaving any further data unposted.

> If I crank up Access and look at the table, it's fine.  I've noticed that
> DoFieldExchange is called 3 times during AddNew and 4 times on Update() -
> it's this 4th time that hoses my program.

> Now before someone says, use CDaoRecordset, let me tell you why not.  These
> record sets are common code that 's used for multiple db sources (Access and
> SQL Server) and I'd rather not incur the overhead of DAO when using SQL
> Server.  I'm not sure that DAO would solve it anyway.

> Anyone else encountered this problem?

> Thanks
> Chuck

This sounds very familiar.  Invalid (uninitialized) CTime's in the recordset can cause a crash under the very conditions you describe.  Years ago when I first encountered this bug it was easy to fix: Initialize the CTime's to any valid date in the recordset constructor.


Wed, 23 May 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. CRecordset access violation

2. CRecordset Access Violation

3. Access Violation when calling CRecordset::Requery()

4. NTDLL.DLL Access Violation in CRecordset-derived class?

5. Access violations once OCBC/CRecordset added to console app

6. CRecordset Open Access violation

7. Access violation in CRecordset.Close()

8. Memory access violation using CRecordset and date/time fields

9. Access Violation when calling CRecordset::Requery()

10. "Access violation" accessing a DLL

11. URGENT: Access Violation when accessing the POOM IAppointment

12. access violation in

 

 
Powered by phpBB® Forum Software