Re:ADO connections and threads
You should create connection inside thread you will use it. COM creates
window in CoInitialize() and processes some messages and messages queue is
unique for thread - so it is better to create COM objects inside thread in
which you will use it.
MSDN: "In general, the simplest way to view the COM threading architecture
is to think of all the COM objects in the process as divided into groups
called apartments. A COM object lives in exactly one apartment, in the sense
that its methods can legally be directly called only by a thread that
belongs to that apartment. Any other thread that wants to call the object
must go through a proxy."
You can try also CoInitializeEx(nil, COINIT_MULTITHREADED) but this way you
will have more problems.
Regards,
Viatcheslav V. Vassiliev
http://www.oledbdirect.com
The fastest way to work with MS SQL Server and MS Jet databases.
"Brett" <brettmetca...@hotmail.com> ???????/???????? ? ???????? ?????????:
news:3d8e99c8@newsgroups.borland.com...
Quote
> Hi
> We have a Delphi 5 application that uses ADO and has three threads in
> addition to the main thread. Two of the threads are used to connect
> to a SQL Server 2000 database, each thread has its own connection that
> it uses exclusively i.e. one connection per thread. We suspect that
> there is a thread problem there as one thread occassionally hangs.
> What I would like to know is do you need to create the connection as
> part of the thread or can you create the connections as part of the
> main program and then point each thread at a single connection. Also
> why you need to do the first method if this is the case.
> Cheers
> Brett