PRB: Data Truncated Error With CRecordset

ID: Q210460


The information in this article applies to:
  • Microsoft Visual C++, 32-bit Editions, version 6.0


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.


REFERENCES

See the documentation for RFX_Text for more information on this function.

Additional query words: kbDSupport truncation rfxtext

Keywords : kbDatabase kbMFC kbODBC kbOracle kbSQLServ kbVC
Version : winnt:6.0
Platform : winnt
Issue type : kbprb


Last Reviewed: April 13, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.