Microsoft KB Archive/181480

= FIX: MFC ODBC Cannot Update Access Date/Time with No Date =

Article ID: 181480

Article Last Modified on 11/21/2006

-

APPLIES TO

 Microsoft Foundation Class Library 4.2, when used with:  Microsoft Visual C++ 5.0 Enterprise Edition

 Microsoft Visual C++ 5.0 Professional Edition

 Microsoft Visual C++ 6.0 Enterprise Edition

 Microsoft Visual C++ 6.0 Professional Edition</li></ul>

 Microsoft Visual C++ 6.0 Standard Edition</li></ul>

 Microsoft Access 2000 Standard Edition</li></ul> </li> Microsoft Data Access Components 2.5</li></ul>

-

<div class="notice_section">

This article was previously published under Q181480

<div class="symptoms_section">

SYMPTOMS
When you update records in an Access database using the ODBC cursor library and you previously added a date/time field in Access without a date using the CRecordset (with TIMESTAMP_STRUCT) classes, MFC throws the following exception:

No Rows Affected

<div class="cause_section">

CAUSE
The ODBC WHERE clause fails to find the record it needs to update it.

<div class="resolution_section">

RESOLUTION
This problem has been fixed in MDAC 2.6. For MDAC versions before 2.6 use the following workarounds:

You must always enter a date in the Access date/time field for CRecordset classes using the ODBC cursor library.

You can also resolve this problem by switching to dynasets.

<div class="status_section">

STATUS
<div class="moreinformation_section">

MORE INFORMATION
If you have to use the ODBC cursor library, you must always enter a date along with a time in the Access date/time field. If you only enter a time, the recordset will fail to post updates and the MFC exception "No Rows Affected" will be thrown. This occurs because the ODBC cursor library attempts to update the database using an UPDATE clause and attempts to select all columns to ensure a unique record. During this selection, the date field fails to be resolved.

If you do not have to use the ODBC cursor library, you can open the recordset as a dynaset, which effectively eliminates this problem.

<div class="references_section">