PRB: ODBC Connection Calls Fail on Multiple Threads
  
PSS ID Number: Q125769
Article last modified on 12-18-1995
 
2.00.2317
 
WINDOWS
 

-----------------------------------------------------------------------
The information in this article applies to:
 
 - Microsoft Open Database Connectivity, version 2.0
-----------------------------------------------------------------------
 
SYMPTOMS
========
 
Although the ODBC Driver Manager and ODBC Cursor Library support
multithreaded applications and drivers, the effectiveness of a
multithreaded ODBC application varies according to the ODBC driver that is
being used. For instance, with the ODBC Desktop Database drivers, only one
thread can make a SQLConnect or SQLDriverConnect call. Other threads in the
same application cannot make the connection calls at any time while the
application is running.
 
In a multithreaded ODBC application, after Thread A has successfully
completed a SQLConnect or SQLDriverConnect call, if Thread B makes a
SQLConnect or SQLDriverConnect call, the following message is received:
 
   Microsoft Access 2.0 driver General error: OleInitialize failed.
 
The same problem will also occur if the Microsoft Foundation Classes (MFC)
database classes are used, and a CDatabase::Open call is issued from more
than one thread (simultaneously or not) during the course of the program.
 
CAUSE
=====
 
The ODBC Desktop Database drivers use OLE, which does not support multiple
threads. However once a connection is made on a thread, the connection
(hdbc) can be shared by other threads.
 
RESOLUTION
==========
 
When using the Desktop drivers, Microsoft recommends connections be made on
only one thread and then shared among different threads. Also, the Desktop
Database 32-bit drivers are thread-safe, but are not effectively
multithreaded. A second thread will block until the first thread completes.
 
Additional reference words: 2.00.2317 Access dbase fox paradox 32bit
MFC database classes Windows NT
KBCategory: kbprg kberrmsg
KBSubcategory:
=============================================================================
Copyright Microsoft Corporation 1995.
