Is Delphi's TADOConnection thread-safe?

允我心安 提交于 2019-11-27 23:54:28

Blorgbeard, you must create, initialize and open a separate TAdoconnection instance for each of your threads.

ADO is a COM-based technology. It uses apartment-threaded objects ,don't forget to call CoInitialize(nil).

procedure TMyThread.Execute;
begin
   CoInitialize(nil);
   try
     try
       // create a connection here
     except
     end;
   finally
     CoUnInitialize;
   end;
end;

No, it is not. ADO is a COM-based technology. It uses apartment-threaded objects, thus you cannot use ADO connections across thread boundaries. Each thread need its own connection.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!