Microsoft KB Archive/210460

= PRB: Data Truncated Error With CRecordset =

Article ID: 210460

Article Last Modified on 9/22/2003

-

APPLIES TO


 * Microsoft Visual C++ .NET 2003 Standard Edition
 * Microsoft Visual C++ .NET 2002 Standard Edition
 * Microsoft Visual C++ 6.0 Enterprise Edition
 * Microsoft Visual C++ 6.0 Professional Edition
 * Microsoft Visual C++ 6.0 Standard Edition

-



This article was previously published under Q210460



SYMPTOMS
When trying to move to record in a wizard-generated recordset, the following error can occur:

Data truncated.

You may also see the following TRACE message in the debug output window:

Error: field data truncated during data fetch.



CAUSE
This error occurs when you are trying to access data in a text field that contains more than 255 characters. If you use the AppWizard or ClassWizard to generate your recordset class, the wizard creates a call to the function RFX_Text to transfer data between the database and your member variable. The fourth parameter of this function specifies the maximum allowed length of the data being transferred and the default value of this parameter is 255.



RESOLUTION
For each call to RFX_Text where the field can contain more than 255 characters, add a fourth parameter that is equal to the maximum length of that field.



STATUS
This behavior is by design.



MORE INFORMATION
Use the AppWizard to create a new MFC project with database support. Use an ODBC data source that contains one or more text fields with data longer than 255 characters.

NOTE: When you build the project and run it, you may see the above error when you try to move to a record that contains long data in the text field. You can see it as soon as the recordset opens, if the first record meets this criteria.

