FIX: CLongBinary Causes "Invalid String or Buffer Length" (156134)
The information in this article applies to:
- The Microsoft Foundation Classes (MFC), when used with:
- Microsoft Visual C++, 32-bit Editions 4.0
- Microsoft Visual C++, 32-bit Editions 4.1
- Microsoft Visual C++, 32-bit Enterprise Edition 4.2
- Microsoft Visual C++, 32-bit Professional Edition 4.2
This article was previously published under Q156134 SYMPTOMS
When updating CLongBinary data using CRecordset::Update(), you may receive
the error "Invalid string or buffer length."
CAUSE
MFC's RFX_LongBinary function uses an obsolete method to specify the size
of the field when binding the CLongBinary buffer for the update. MFC
specifies that the length of the long binary field is SQL_DATA_AT_EXEC, a
symbol that signifies that data is transferred via SQLPutData() without
providing any information about the field's size.
The following is true according to the documentation for SQLExecDirect
(Problems and Information) in the ODBC SDK 2.10 Release Notes, included
with VC++ 4.1:
SQLSTATE S1090 (Invalid string or buffer length):
A parameter length value bound by SQLBindParameter was set to
SQL_DATA_AT_EXEC; the SQL type was either SQL_LONGVARCHAR,
SQL_LONGVARBINARY, or a long, data-source specific data type; and the
SQL_NEED_LONG_DATA_LEN information type in SQLGetInfo was "Y."
The 32-bit Intersolve 2.11 Oracle 7 ODBC driver for NT and Windows 95
returns this error, which may also be returned by other ODBC drivers
that meet the above criteria.
RESOLUTION
To avoid this error, you can modify MFC to use the SQL_LEN_DATA_AT_EXEC()
macro that provides information about the size of the data and thereby
allows the driver to perform the update.
STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed
at the beginning of this article. This bug was corrected in Visual C++
version 5.0.
REFERENCES
ODBC Programmer's Reference
ODBC SDK 2.10 Release Notes
Modification Type: | Major | Last Reviewed: | 12/10/2003 |
---|
Keywords: | kbbug kbDatabase kbfix kbVC500fix KB156134 |
---|
|