Microsoft KB Archive/257556

= FIX: DB_E_ERRORSOCCURRED When ODBC Driver Returns TABLE_TYPE of More than 15 Characters =

Article ID: 257556

Article Last Modified on 10/17/2003

-

APPLIES TO


 * Microsoft Data Access Components 2.1
 * Microsoft Data Access Components 2.5

-



This article was previously published under Q257556



SYMPTOMS
The Microsoft OLE DB Provider for ODBC Drivers method IDBSchemaRowset::GetRowSet fails with DB_E_ERRORSOCCURRED when an ODBC driver returns a TABLE_TYPE string of more than 15 characters.

The specific error is:

Run-time Error '-2147217887 (80040e21): Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.

You may experience this error from ActiveX Data Objects (ADO) with an OpenSchema(AdSchemaTables) method call if a recordset is created with the Microsoft ODBC OLE DB Provider for ODBC Drivers and an ODBC driver that returns a TABLE_TYPE string of at least 16 characters.



CAUSE
The Microsoft ODBC OLE DB Provider for ODBC Drivers generates an ODBC SQLTable call to return information about tables in the database being accessed by the ODBC driver. The TABLE_TYPE information is bound to an ANSI character buffer that is 32 bytes in length. Once the information is returned, the provider processes the list of tables for the recordset and automatically converts the ANSI characters to UNICODE, which doubles the size of the string. A character string of 16 bytes is doubled to result in a string, including the null terminator, that is bigger than the initial 32-character buffer. This situation is detected by the ODBC Provider, which then returns "DB_E_ERRORSOCCURRED".



RESOLUTION
You can avoid this problem by restricting the TABLE_TYPE character string returned by the ODBC driver in response to the SQLTable call to 15 characters. An alternative is to avoid using the ADO OpenSchema(AdSchemaTables) method with the Microsoft ODBC OLE DB Provider and an ODBC driver that returns a TABLE_TYPE string longer than 15 characters in response to the SQLTable call.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

This bug was corrected in Microsoft Data Access Components (MDAC) 2.6.

Keywords: kbbug kbfix kbmdac260fix KB257556

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.