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



The information in this article 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_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.

Modification Type:MajorLast Reviewed:5/28/2003
Keywords:kbdocerr kbprb KB325243