The ADO thread is not secure and UNIDAC is using MSSQL as well. Actually this is Microsoft COM problem, not blame Devart company.
The general workaround is to start CoInitialize (nil) on the thread and end the call to CoUninitialize. If you use a variety of database connections, such as the three layer often switch to MSSQL and Oracle, we only need to determine the Tuniconnection connection before the event Onbeforeconnect write down the following code:
Procedure Tservdbfunc.servconnbeforeconnect (Sender:tobject);
Begin
if (Servconn <> nil) and Sametext (Servconn.providername, ' SQL Server '); then
CoInitialize (nil);
End
After the Tuniconnection closed connection event Onafterdisconnect write the following code:
Procedure Tservdbfunc.servconnafterdisconnect (Sender:tobject);
Begin
if (Servconn <> nil) and Sametext (Servconn.providername, ' SQL Server '); then
CoUninitialize;
End
Note that you must first determine if the connection control (Servconn <> nil) is empty, otherwise you will fall into the issue of pointer release.
Transferred from: http://hi.baidu.com/tintinsoft/item/361a8255237b0dc49f266761
http://blog.csdn.net/rznice/article/details/8252775
Issues to be aware of using unidac+mssql under multithreading (using CoInitialize)