PRB: HENV Not Accessible When Using MFC ODBC Classes

ID: Q167910

The information in this article applies to:

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

Additional query words: kbVC420 kbVC500 kbVC600
Keywords          : kbinterop kbDatabase kbMFC kbODBC kbVC 
Version           : 4.2 4.2b 5.0
Platform          : NT WINDOWS
Issue type        : kbprb

Last Reviewed: August 8, 1998