PRB: HENV Not Accessible When Using MFC ODBC Classes

Last reviewed: August 7, 1997
Article ID: Q167910
The information in this article applies to:
  • Microsoft Visual C++, 32-bit Editions, versions 4.2, 4.2b, 5.0
  • The Microsoft Foundation Classes (MFC) included with: - Microsoft Visual C++, 32-bit Editions, versions 4.2, 5.0

SYMPTOMS

When you dynamically link to MFC, the MFC ODBC classes use an ODBC environment handle (HENV) that is declared local to the MFC DLL. Therefore, applications using the MFC DLL cannot access MFC's HENV.

CAUSE

These classes were not designed to make the HENV available to the programmer.

RESOLUTION

If you need access to the HENV, link MFC statically and use the code below.

STATUS

Microsoft is researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

Sample Code

   #include "c:\\msdev\\mfc\\src\\dbimpl.h"

   _AFX_DB_STATE* pDbState = _afxDbState;
   // call ODBC API functions using pDbState->m_henvAllConnections
Keywords          : MfcDatabase kbinterop
Technology        : kbMfc
Version           : 4.2 4.2b 5.0
Platform          : NT WINDOWS
Issue type        : kbprb


================================================================================


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: August 7, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.