Microsoft KB Archive/128894

= PRB: C2189 and C2857 Errors When AFXDB.H Used for UNICODE =

Article ID: 128894

Article Last Modified on 11/21/2006

-

APPLIES TO

 Microsoft Foundation Class Library 4.2, when used with:  Microsoft Visual C++ 2.0 Professional Edition

 Microsoft Visual C++ 2.1 

-



This article was previously published under Q128894



SYMPTOMS
When attempting to build an AppWizard-generated DLL or EXE with ODBC support, two compiler errors are generated when STDAFX.CPP is compiled :

\msvc20\mfc\include\afxdb.h(15): error C2189: #error: Database classes not supported in this library variant.

\stdafx.cpp(7): error C2857: '#include' statement specified with the /Ycstdafx.h command-line option was not found in the source file.

<div class="cause_section">

CAUSE
The project settings for the DLL or EXE have been changed so that _UNICODE is defined, instead of _MBCS.

When using AppWizard to generate a DLL or an EXE with ODBC support, AppWizard automatically adds the following to the STDAFX.H file it generates: #include <afxdb.h> However, ODBC does not support Unicode, so MFC produces a compilation error whenever an attempt is made to build a Unicode application or DLL that includes the MFC database classes header file (AFXDB.H).

<div class="resolution_section">

RESOLUTION
<ol>  If you are not using the MFC database classes, remove the following line from your STDAFX.H file: #include <afxdb.h>                       </li> If you are using the MFC database classes, do not build a Unicode variant of your DLL or EXE. The database classes rely on ODBC, which does not support Unicode.</li></ol>

<div class="status_section">

STATUS
This behavior is by design.

Additional query words: 2.00 2.10 dll unicode database

Keywords: kbdatabase kbdll kbprb kbwizard KB128894

-

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

© Microsoft Corporation. All rights reserved.