Article ID: 151407 - Last Review: November 21, 2006 - Revision: 2.1

PRB: DAO 3.0 Must Be Used in Primary Thread

This article was previously published under Q151407
Expand all | Collapse all

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:
150777  (http://support.microsoft.com/kb/150777/EN-US/ ) Descriptions and Workings of OLE Threading Models
Tech Note #64: Apartment-Model Threading in OLE Controls

REFERENCES

147629  (http://support.microsoft.com/kb/147629/EN-US/ ) PRB: Problems if ODBC or DAO in DLL's InitInstance or DLLMain

APPLIES TO
  • Microsoft Foundation Class Library 4.2, when used with:
    • Microsoft Visual C++ 4.0 Standard Edition
    • Microsoft Visual C++ 4.1 Subscription
    • Microsoft Visual C++ 4.2 Enterprise Edition
    • Microsoft Visual C++ 4.2 Professional Edition
Keywords: 
kbdatabase kbprb kbprogramming kbusage KB151407
Retired KB ArticleRetired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.
 

Article Translations