PRB: CLongBinary Field Truncated with SQL Server ODBC DriverLast reviewed: July 18, 1997Article ID: Q126264 |
1.50 1.51
WINDOWS
kbprg kbprb
The information in this article applies to:
SYMPTOMSWhen trying to update a CLongBinary field using the ODBC SQL Server driver, the data is truncated.
CAUSEThe RFX_LongBinary code tries to transfer the CLongBinary field data in 32K byte chunks, but the default maximum amount of data the SQL Server ODBC driver version can transfer at a time is 4K bytes. This only applies to driver manager (ODBC.DLL), cursor library (ODBCCURS.DLL), and SQL server driver (SQLSRVR.DLL) that came with Visual C++ version 1.50 or 1.51.
RESOLUTIONThe newer ODBC SQL Server driver doesn't have a limitation on the transfer size. It is included with Visual C++ version 1.52, with the ODBC SDK version 2.1, and with the ODBC Driver pack version 2.0. If you aren't using the newest SQL Server driver, you can work around the problem by using the ODBC API SQLSetStmtOptions() function to set the maximum amount of data that the SQL Server driver can transfer at one time. Set the value to something larger than 32K bytes.
STATUSThis behavior is by design.
MORE INFORMATIONThe MFC CRecordset class has a virtual function OnSetOptions() that is a good place to make the SQLSetStmtOptions() call. In that call, specify SQL_MAX_LENGTH as the second parameter and a value of 32K bytes or greater as the third parameter. The override of the OnSetOptions() function should look something like this:
void CMyRecordset::OnSetOptions(HSTMT hstmt) { SQLSetStmtOption(hstmt,SQL_MAX_LENGTH,(UDWORD)100000); CRecordset::OnSetOptions(hstmt); } REFERENCESFor more information about other problems with CLongBinary fields, please see the following article in the Microsoft Knowledge Base:
ARTICLE-ID: Q118758 TITLE : BUG: & FIX: Problems that Occur When Using CLongBinary Field |
Additional reference words: 1.50 1.51 2.5 2.51 2.52
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |