"String Data, Length Mismatch" Error Message with ODBC Driver for SQL Server If Application Inserts More Than 400 KB of Text Data (325765)
The information in this article applies to:
- Microsoft ODBC Driver for SQL Server 3.7
- Microsoft ODBC Driver for SQL Server 2000 2000.80.194
- Microsoft ODBC Driver for SQL Server 2000 2000.80.380
- Microsoft ODBC Driver for SQL Server 2000 2000.81.7713.0
- Microsoft Data Access Components 2.5
- Microsoft Data Access Components 2.6
- Microsoft Data Access Components 2.7
This article was previously published under Q325765 SYMPTOMS
If an application inserts more than 400 kilobytes (KB) of data in SQL Server by using ODBC, you may receive the following error message:
DIAG [22026] [Microsoft][ODBC SQL Server Driver]String data, length mismatch (0)
You receive this error message if the application uses the ODBC application programming interface (API) directly (that is, the SQLBindParameter, the SQLParamData, the SQLExecute, and the SQLPutData APIs). Additionally, you receive this error message if you try to insert data through a Microsoft Access linked table to SQL Server, and if all of the following conditions are true:
- The application inserts more than 400 KB of data.
- The application calls SQLBindParameter with SQL_C_WCHAR and SQL_LONGVARCHAR. If the application links with Access, Access calls SQLBindParameter with SQL_C_WCHAR and SQL_LONGVARCHAR.
- The server data type is non-Unicode such as "text." Internally, this causes the SQL Server driver to convert the data that you have passed from Unicode to MultiByte.
- The application uses the SQL_LEN_DATA_AT_EXEC(409602) macro to indicate that you are trying to send more than 400 kilobytes of data. If you are using Access, Access uses this macro automatically.
This problem occurs with the ODBC Driver for SQL Server that is included with Microsoft Data Access Components (MDAC) versions 2.5, 2.6, and 2.7.
CAUSE
Based on the ODBC specification, when a client calls SQL_LEN_DATA_AT_EXEC and passes a number as its parameter, such as SQL_LEN_DATA_AT_EXEC(409602), the number that is passed indicates how many bytes of data is sent when the client calls SQLPutData later. This problem occurs because the ODBC Driver for SQL Server incorrectly interprets this number as the number of characters that are passed instead of number of bytes that are passed.
RESOLUTIONA supported hotfix is now available from Microsoft, but it is only intended to correct the problem that is described in this article. Only apply it to systems that are experiencing this specific problem. This hotfix may receive additional testing. Therefore, if you are not severely affected by this problem, we recommend that you wait for the next Microsoft Data Access Components service pack that contains this hotfix. To resolve this problem immediately, contact Microsoft Product Support Services to obtain the fix. For a complete list of Microsoft Product Support Services phone numbers and information about support costs, visit the following Microsoft Web site: NOTE: In special cases, charges that are ordinarily incurred for support calls may be canceled if a Microsoft Support Professional determines that a specific update will resolve your problem. The typical support costs will apply to additional support questions and issues that do not qualify for the specific update in question.
The English version of this fix has the file attributes (or later) that are listed in the following table. The dates and times for these files are listed in coordinated universal time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time tool in Control Panel.
Date Version Size File Name Platform
---------------------------------------------------------------
12-Jul-2002 2000.081.9001.011 24,576 Odbcbcp.dll x86
12-Jul-2002 2000.081.9001.011 356,352 Sqlsrv32.dll x86
12-Jul-2002 2000.081.9001.011 90,112 Sqlsrv32.rll x86
WORKAROUND
To work around this problem, bind the parameter as SQL_C_CHAR (instead of as SQL_C_WCHAR), and then pass non-Unicode data.
If you are using an Access linked table to update your SQL Server table, you cannot use this workaround because Access always binds text parameters as SQL_C_WCHAR.
STATUSMicrosoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.
Modification Type: | Minor | Last Reviewed: | 10/11/2005 |
---|
Keywords: | kbHotfixServer kbQFE kbbug kbfix kbQFE KB325765 |
---|
|