The information in this article applies to:
SYMPTOMS
The CRecordset::Update() function fails to correctly update a text field if
that field is changed from a null value to a non-null value. The Update()
function may return FALSE or, if the dirty flag is set for the field, the
Update() function may return TRUE but a null value will be written to the
record instead of the expected non-null value.
CAUSEThe RFX_Text() function, which maps a CString to a text field, has changed in Visual C++ version 2.0. In Visual C++ version 1.51, you'll see the following code in the MarkForUpdate operation of the RFX_Text() function:
This code was removed in Visual C++ version 2.0. The code checks to see if
a CString is empty and sets or resets the null flag accordingly. Without
this code, the null flag for a field will remain set even though you may
change the contents of a CString field variable. Because this code is no
longer present in the Visual C++ version 2.0 database classes code, you
will have to set or reset the null flag for a text field in your code.
RESOLUTION
If you use a CRecordView for retrieving data, you won't notice the bug
because a CRecordView sets or resets a field's null flag depending on
whether a user has entered text into the edit control representing that
field. The DDX_FieldText() function does the work of setting the field's
null flag.
You can see how the null flag for the field is set or reset. You can write
similar code to handle setting or resetting the null flag in your code.As an alternative, you can create a new RFX function, and insert the code shown above for the MarkForUpdate operation. Replace the call to RFX_Text() in your CRecordset's DoFieldExchange() function with your new RFX function. STATUSMicrosoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This bug was corrected in Visual C++ 2.1. REFERENCES
For more information about Record Field Exchange (RFX) functions see the
following references:
Additional query words: 2.00 3.00
Keywords : kbDatabase kbMFC kbODBC kbVC |
Last Reviewed: July 30, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |