FIX: CString::Format( ) Involving Floats Reallocates the Default Bound ODBC Text BufferID: Q216443
|
While performing the CRecordset::Update( ) function using dynaset cursors on a table containing a numeric or decimal field(s) the following error message appears:
This happens when the CString::Format( )operation involving floating point numbers is performed on a CString member variable bound to the decimal or numeric field(s) in the table prior to the update.Debug Assertion Failed!
Program: Name of the Program
File: dbrfx.cpp
Line: 287
In Visual C++ version 6.0, the minimum number of characters to represent a float in a CString has been increased from 128 to 312. By default, RFX_Text( ) binds a 256 byte buffer to a text column if a CString::Format( ) is performed on a CRecordset bound member variable as in the following example:
CString m_MemberVariable;
m_MemberVariable.Format("%7.2f ",111.11);
Consequently, the buffer is reallocated. In MFC ODBC, a variable is bound to a field in the table only during CRecordset::Open( ). Once bound, its binding address must remain valid as long as the ODBC binding remains in effect. The reallocation causes this binding address to change and results in the debug assertion.
Set the fourth parameter of RFX_Text (nMaxLength) to be greater than or equal to 312. This ensures that the CString buffer allocated for the variable bound to the numeric or decimal field is at least 312 bytes, thereby avoiding the reallocation on a CString::Format( ).
Microsoft has confirmed this to be a bug in the Microsoft products listed
at the beginning of this article.
This bug was corrected in Visual Studio 6.0 Service Pack 3.
For more information about Visual Studio 6.0 Service Packs, please see the following articles in the Microsoft Knowledge Base:
Q194022 INFO: Visual Studio 6.0 Service Packs, What, Where, Why
Q194295 HOWTO: Tell That Visual Studio 6.0 Service Packs Are Installed
Q197448 PRB: CRecordset "String Cannot Be Converted To Number" Error
Additional query words:
Keywords : kbdocfix kbservicepack kbDatabase kbMFC kbVC600 kbVS600sp3fix kbGrpVCDB
Version : WINDOWS:3.51,6.0
Platform : WINDOWS
Issue type : kbbug
Last Reviewed: May 19, 1999