Microsoft KB Archive/121217

{|
 * width="100%"|

FIX: "No rows were affected by the update or delete operation"

 * }

Q121217

-

The information in this article applies to:


 * The Microsoft Foundation Classes (MFC), included with:
 * Microsoft Visual C++, version 1.5

-

SYMPTOMS
When using snapshots with the Microsoft Foundation Class Library database classes, the following error message occurs:

Warning: ODBC Success With Info, Warning: 0 rows affected by

update operation (expected 1).

No rows were affected by the update or delete operation.

CAUSE
This message may occur because of a bug in the ODBC cursor library (ODBCCURS.DLL). In the following scenarios, the cursor library incorrectly handles modifying of fields that have a pre-defined length (such as numeric fields and everything that is not a text field and not a variable length field):


 * A field in a table is null and an application changes the field to a non-null value. After the field has been updated to the non-null value, subsequent updates fail.
 * A field in a table is non-null and an application changes the field to a null value. After the field has been updated to a null value, subsequent updates fail.

The cursor library incorrectly updates the snapshot values in these cases. The bug won't occur if the snapshot is refreshed between updates by doing a requery.

RESOLUTION
Use one of the following techniques to work around the problem:


 * Requery after each update. In other words, set the field to null, and requery. Then set the field to non-null and requery, and so on.
 * Use text fields in situations where the data may be changing from null to non-null data or vice versa.

STATUS
Microsoft has confirmed this to be a bug in the ODBC cursor library included in Microsoft Visual C++ version 1.5. The ODBC cursor library included in Microsoft Visual C++ version 1.51 fixes the problem.