Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

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


View products that this article applies to.

This article was previously published under Q325243

↑ Back to the top


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.

↑ Back to the top


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_XXXX 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_XXXX 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.

↑ Back to the top


Keywords: KB325243, kbdocerr, kbprb

↑ Back to the top

Article Info
Article ID : 325243
Revision : 2
Created on : 5/28/2003
Published on : 5/28/2003
Exists online : False
Views : 270