Q151407: PRB: DAO 3.0 Must Be Used in Primary Thread
Article: Q151407
Product(s): Microsoft C Compiler
Version(s): 4.0 4.1 4.2
Operating System(s):
Keyword(s): kbprogramming kbusage kbDAOsearch kbDatabase kbMFC kbVC
Last Modified: 30-JUL-2001
-------------------------------------------------------------------------------
The information in this article applies to:
- The Microsoft Foundation Classes (MFC), included with:
- Microsoft Visual C++, 32-bit Editions, versions 4.0, 4.1
- Microsoft Visual C++, 32-bit Enterprise Edition, version 4.2
- Microsoft Visual C++, 32-bit Professional Edition, version 4.2
-------------------------------------------------------------------------------
SYMPTOMS
========
Attempting to use either the MFC DAO classes or the DAO SDK dbDao classes in any
thread but the primary one causes unexpected behavior.
CAUSE
=====
DAO 3.0 is not marked as apartment-model or free-threaded in the registry. No
multithreading testing has been done on DAO 3.0. Any documentation should say
that DAO 3.0 is not thread-safe and should only be used in the primary thread in
a process.
RESOLUTION
==========
Do not use MFC DAO or the DAO SDK dbDao classes in any thread but the primary
thread of an application.
STATUS
======
This behavior is by design.
MORE INFORMATION
================
Internally, the Jet engine is multithreaded, and the registry setting
\HKEY_LOCALMACHINE\Software\Microsoft\Jet\3.0\Engines\Jet\Threads controls the
number of threads that the engine uses internally. The Jet engine is
multithreaded internally, but neither DAO nor the Jet engine are thread- safe.
For more information on OLE threading models, see the following article in the
Microsoft Knowledge Base:
Q150777 Descriptions and Workings of OLE Threading Models
Tech Note #64: Apartment-Model Threading in OLE Controls
REFERENCES
==========
Q147629 PRB: Problems if ODBC or DAO in DLL's InitInstance or DLLMain
======================================================================
Keywords : kbprogramming kbusage kbDAOsearch kbDatabase kbMFC kbVC
Technology : kbAudDeveloper kbMFC
Version : 4.0 4.1 4.2
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.
Copyright Microsoft Corporation 1986-2002.