Solving the ODBC "Data truncated" error

When you derive a class from CRecordset, the default maximum length assigned by the AppWizard for a string or array during a transfer is 255. A "Data Truncated" error is displayed whenever you attempt to transfer records with fields bigger than that.

To solve the problem, specify the length required as the fourth parameter of the RFX_Text() function in the AFX_FIELD_MAP section of your CRecordset derived class method file. The maximum length you can set it to is INT_MAX (2147483647) which is the maximum length of a CString object.

The source below shows the COST_INFO and BENEFITS columns of the table accessed being assigned a maximum length of 1000 characters each.


//{{AFX_FIELD_MAP(CProjectsSet)
RFX_Text(pFX, _T("[COST_INFO]"), m_COST_INFO, 1000);
RFX_Text(pFX, _T("[BENEFITS]"), m_BENEFITS, 1000);
//}}AFX_FIELD_MAP




Comments

  • Is this true for SQL server 6.5

    Posted by Legacy on 03/10/1999 12:00am

    Originally posted by: Tommy Quitt

    As much as I know, Ms SQL server 6.5 does not support longer strings that 255 chars.
    Is this true or does this RFX_TEXT change will allow longer strings on SQL server 6.5 too?

    Tommy

    Reply
  • Problems with changing RFX_Text...

    Posted by Legacy on 01/07/1999 12:00am

    Originally posted by: Alexander Keck

    Hi there!
    
    

    The same problem occures if you use Binary fields.
    RFX_Binary() also supports the third parameter for the maximum length, witch is also 255 as default.
    This works verry well here, BUT the ClassWizzard is unable to handle this.... It allways shows up a Messagebox telling you:
    Parsing Error: Expected ")".
    Input Line: "RFX_Binary(pFC, _T([Fieldname]"), m_Variable, 1000);"

    Possible Solution (not testet until now):
    Place the RFX_Text (or RFX_Binary) outside the ClassWizzard Insert comments:
    //{{AFX_FIELD_MAP(CCLClientBinaryRecordset)
    RFX_Text(pFX, _T("[TextField]"), m_Text);
    //}}AFX_FIELD_MAP
    RFX_Binary(pFX, _T("[BinaryField]"), m_Binary, 0x40000);

    greetings
    Alex

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • All businesses have a core set of applications that are critical to successful growth. These applications require a higher level of availability than other applications and services in the organization. There is a trade-off, however, to increasing application availability through traditional high-availability clustering. Businesses can see costs surge in terms of additional hardware and clustering software/support, as well as additional costs and complexities due to increased operational management …

  • Intelligent N+X Redundancy, Placement Affinities, & Future Proofing in the Virtualized Data Center Virtualization brought about the ability to simplify business continuity management in IT. Workload portability and data replication capabilities mean that physical infrastructure failures no longer need impact application services, and they can rapidly be recovered even in the event of complete site failure. However, Enterprises and Service Providers face new challenges ensuring they have enough compute …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds