Export (0) Print
Expand All
MFC
Expand Minimize

TN067: Database Access from an ISAPI Server Extension 

NoteNote

As of Visual C++ .NET, the Visual C++ environment and wizards no longer support DAO (although the DAO classes are included and you can still use them). Microsoft recommends that you use OLE DB Templates or ODBC and MFC for new projects. You should only use DAO in maintaining existing applications.

ISAPI server extensions are DLLs. They work in the process space of the server. Concurrent requests made to an ISAPI extension are handled by separate threads. Therefore, the code in an ISAPI extension must be thread-safe.

Database access methods that use COM to handle initialization are not thread-safe. The specific problem lies in initializing the COM libraries in one thread and then using another thread to access the data. The current implementation of the Microsoft ODBC Desktop Drivers falls into this category. These drivers (dBase, Microsoft Access, Microsoft Excel, Paradox, and Text) that ship with Visual C++ use the Microsoft Jet 3.0 database engine, which is not thread-safe. Also, Data Access Objects (DAO) is a COM-based API, so it does not run reliably in the multithreaded environment of an ISAPI extension.

There may be other database access methods that are not thread-safe.

To access a database from an ISAPI server extension, use an ODBC driver that has been designed and tested for multithreaded use. Microsoft's ODBC drivers for Microsoft SQL Server 6.x are an example.

The MFC ODBC database classes are thread-safe as of MFC 4.2. Be sure that any ODBC database driver you use with these classes is also thread-safe.

Applications that use the MFC ODBC database classes before version MFC 4.2 need to have the database code placed inside a critical section to ensure that only one thread accesses the MFC database code at a time. For more information, see class CCriticalSection.

Currently, the MFC DAO database classes are not thread-safe because they use the DAO COM-based objects.

Community Additions

ADD
Show:
© 2014 Microsoft