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

  • With JRebel, developers get to see their code changes immediately, fine-tune their code with incremental changes, debug, explore and deploy their code with ease (both locally and remotely), and ultimately spend more time coding instead of waiting for the dreaded application redeploy to finish. Every time a developer tests a code change it takes minutes to build and deploy the application. JRebel keeps the app server running at all times, so testing is instantaneous and interactive.

  • The latest release of SugarCRM's flagship product gives users new tools to build extraordinary customer relationships. Read an in-depth analysis of SugarCRM's enhanced ability to help companies execute their customer-facing initiatives from Ovum, a leading technology research firm.

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds