The information in this article applies to:
SYMPTOMSTrying to run a program that contains a call to CDatabase::ExecuteSQL() that has been built for UNICODE results in a CDBException being thrown with an error message from the ODBC driver. The message depends on the SQL Statement and the ODBC driver. For example, trying to execute an INSERT statement on a data source that uses the Microsoft Access ODBC driver results in the following error message:
CAUSEThe SQL string passed to CDatabase::ExecuteSQL() is a UNICODE string, and the ODBC API expects all arguments that are strings to be ASCII strings. RESOLUTION
To work around this bug, you have to convert the string yourself, and then
cast the resultant ASCII string to an LPCTSTR when you pass it to
CDatabase::ExecuteSQL(). The cast is necessary because
CDatabase::ExecuteSQL() expects a wide character string.
To make the code work, you need to use code similar to this code:
STATUSMicrosoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This bug was corrected in Visual C++ 4.1. MORE INFORMATIONIn general, you can use the MFC ODBC classes in UNICODE programs. The MFC ODBC classes will handle the UNICODE/ASCII conversions for ODBC API calls. CDatabase::ExecuteSQL() is missing this conversion support. Additional query words: kbVC400bug
Keywords : kbDatabase kbMFC kbODBC kbVC kbVC410fix |
Last Reviewed: July 22, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |