Click to See Complete Forum and Search --> : ODBC error "data truncated"


Dmitriy
September 3rd, 1999, 07:45 AM
What does this error mean? I have a field with large amount of data - 4k-8k text (variable ntext) in SQL Server. How can I read this field?
I think, I've received this error due to large amount of bytes in this field. Has ODBC limit to pass data throw?


Good luck!

Dmitriy, MCSE

Oleg Lobach
September 3rd, 1999, 08:10 AM
Hi,

Look at MSDN article "Retrieving Variable-Length Data in Parts":

SQLGetData can be used to retrieve data from a column that contains variable-length data in parts — that is, when the identifier of the SQL data type of the column is SQL_CHAR, SQL_VARCHAR, SQL_LONGVARCHAR, SQL_WCHAR, SQL_WVARCHAR, SQL_WLONGVARCHAR, SQL_BINARY, SQL_VARBINARY, SQL_LONGVARBINARY, or a driver-specific identifier for a variable-length type.

To retrieve data from a column in parts, the application calls SQLGetData multiple times in succession for the same column. On each call, SQLGetData returns the next part of the data. It is up to the application to reassemble the parts, taking care to remove the null-termination character from intermediate parts of character data. If there is more data to return, SQLGetData returns SQL_SUCCESS_WITH_INFO and SQLSTATE 01004 (Data truncated). When it returns the last part of the data, SQLGetData returns SQL_SUCCESS. Neither SQL_NO_TOTAL nor zero can be returned on the last valid call to retrieve data from a column, because the application would then have no way of knowing how much of the data in the application buffer is valid. If SQLGetData is called after this, it returns SQL_NO_DATA. For more information, see the next section, “Retrieving Data with SQLGetData.”

Hope this helps,
Oleg.

Oleg Lobach
September 3rd, 1999, 08:13 AM
Also look at Article ID: Q182386 in MSDN.
Regards,
Oleg.