INFO: Thread Safety and the Access ODBC DriverLast reviewed: May 12, 1997Article ID: Q167907 |
The information in this article applies to:
SUMMARYThere are some limitations when you use the Access ODBC Driver in multi- threaded applications.
MORE INFORMATIONThe Versions of the Access ODBC driver that shipped with versions 4.2 and earlier of Visual C++ (or as version 3.0 of the desktop drivers) has limitations when you use it in multithreaded applications. You cannot pass connection and statement handle values from one thread to another. This also means that CDatabase and CRecordset MFC objects cannot be shared between threads. The reason for this is that the Jet database engine utilized VBA, which supports the Apartment Model of thread safety rather than free-thread safety. Although the Access ODBC Driver, internally, put a critical section around every call to the Jet engine, the use of VBA made the sharing of connection and statement handles unsafe. As long as the thread in the application that initiated a connection to the Access Driver is the only one that does work on that connection, everything is fine. However, it is not safe to pass the connection handle onto another thread and have that thread do work on that connection. The multithreaded capabilities of the desktop drivers that ship with Visual C++ 5.0 (or as version 3.5 of the desktop drivers) have improved. It is now safe to share connection handles between threads. However, the thread that creates the connection must also free it. It is still not safe to share statement handles. This means that it is safe to share CDatabase objects but not CRecordset objects. |
Keywords : MfcDatabase
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |