Multi-threaded MSSQL dbExpress Driver Usage

Abstract: For multi-threaded usage of the Delphi 2007 MSSQL dbExpress driver the COM coinitialize and couninitialize should be called for all threads that use this driver.

The Microsoft SQL Server dbExpress driver will automatically call coinitialize when the driver is loaded. If this initial call to counitialize succeeds, the driver will also:

Call couninitialize when the driver is unloaded.

Call coinitialize when a new connection is made.

Call counitialize when a connection is closed.

The apartment threading model is used to all automatic calls to coinitialize made by the driver.

If a different threading model is needed, or there are any other problems using this driver with a multiple threaded application, it is best it the application calls coinitialize and counitialize for all threads that use this driver:

Call coinitialize when the application starts and couninitialize before the application exits.

Call coinitialize when a secondary thread starts and couninitialize before the secondary thread exits.