Microsoft KB Archive/167910

{| = PRB: HENV Not Accessible When Using MFC ODBC Classes =
 * width="100%"|

ID: Q167910

The information in this article applies to:


 * The Microsoft Foundation Classes (MFC) included with: - Microsoft Visual C++, 32-bit Editions, versions 4.2, 5.0, 6.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.

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
 * }