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

  • Packaged application development teams frequently operate with limited testing environments due to time and labor constraints. By virtualizing the entire application stack, packaged application development teams can deliver business results faster, at higher quality, and with lower risk.

  • With 81% of employees using their phones at work, companies have stopped asking: "Is corporate data leaking from personal devices?" and started asking: "How do we effectively prevent corporate data from leaking from personal devices?" The answer has not been simple. ZixOne raises the bar on BYOD security by not allowing email data to reside on the device. In addition, Zix allows employees to maintain complete control of their personal device, therefore satisfying privacy demands of valued employees and the …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds