The information in this article applies to:
SYMPTOMSWhen you map a control to a recordset variable by using DDX_FieldCBString or DDX_FieldLBString, the following message may appear in a messagebox when UpdateData() is called:
CAUSEThe DDX_FieldCBString and DDX_FieldLBString functions incorrectly check the length of the destination CString variable. The problem exists on lines 420 and 509 in Daoview.cpp. The code is performing the following check;
It is possible that the buffer for the string has been emptied by a call to
AddNew() or SetFieldNull(). This would cause the CString value to be empty,
which causes the messagebox to be displayed.
RESOLUTION
Create a new function by copying the DDX_FieldCBString or DDX_FieldLBString
from Daoview.cpp located in the \Msdev\Mfc\Src directory. In the new
function, add an additional parameter to be used as the maximum allowable
length (the size of the field). You'll then need to replace the DDX call in
your DoDataExchange() function with the new function you created.
Replace these lines:
with these lines:
Note that GetBuffer() is no longer receiving 0 but is using the value
in nLen.
For the DDX_FieldLBString() function, change the prototype to:
Replace these lines:
with these lines:
You will need to include a prototype for AfxFailMaxChars() in your code.
Here's the prototype:
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++ 4.1. Additional query words: kbVC400bug
Keywords : kbDAO kbDatabase kbMFC kbVC kbVC410fix |
Last Reviewed: January 31, 2000 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |