Microsoft KB Archive/325243

= DOC: ODBC Driver Manager Does Not Convert SQL Types Based on the Nature of the Driver =

Article ID: 325243

Article Last Modified on 5/28/2003

-

APPLIES TO


 * Microsoft Data Access Components 2.0
 * Microsoft Data Access Components 2.1
 * Microsoft Data Access Components 2.5
 * Microsoft Data Access Components 2.6
 * Microsoft Data Access Components 2.7

-



This article was previously published under Q325243



SUMMARY
When a Unicode application calls the SQLBindParameter function with the SQL_WCHAR SQL type, the ODBC Driver Manager does not convert the SQL type to SQL_CHAR before it passes to an ANSI driver. However, the ODBC Driver Manager does convert the C type to SQL_C_CHAR in this scenario. This is by design.

The ODBC Programmer's Reference: Unicode Data Web site incorrectly states:

If an application working with a non-Unicode driver binds to SQL_WCHAR, the Driver Manager will map the SQL_WCHAR data to SQL_CHAR.



MORE INFORMATION
The SQL type parameter (the fifth parameter) for SQLBindParameter describes the data type on the database server. The ODBC Driver Manager must not change this for the UNICODE or the ANSI types. The ODBC Driver Manager handles the mapping for C data types (that is, the SQL_C_ types), depending on the nature of the driver (ANSI or UNICODE) and data on the client side. However, the ODBC Driver Manager does not handle the mapping for the SQL data types (that is, the SQL_ types).

To work around this design feature, use one of the following methods:
 * Have the application use the SQLDescribeParam or the SQLDescribeCol function to discover the SQL type of the parameter or the column respectively, and then adjust the SQL type parameter accordingly.
 * Have the driver internally convert to the SQL type that you want.

Because the ODBC Driver Manager must work for all drivers, the ODBC Driver Manager cannot map the SQL type.

Keywords: kbprb kbdocerr KB325243

-

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

© Microsoft Corporation. All rights reserved.