Board index » delphi » Threaded ADO Connections

Threaded ADO Connections

Just curious, why do you wrap the query open in a crit section?

...anyway, here's how I do threaded ADO:

drop the requisite objects on a TDataModule - TADOConnection, TADOQuery,
etc.
make sure everything works there - test connection at design time, etc.

create the datamodule dynamically, in the thread, after CoInit.
Open the connection
run the query.
do stuff.
close conn
free the Datamodule
CoUninit.

Thing is, I've done it your way*, and it works fine. Have you tried the
TCP/IP network library option for the ADOConnection?

*Only on NT4SP3+ or Win2k

 

Re:Threaded ADO Connections


Hi,

I have an Delphi 5 app which uses ADO2.6 to Access a SQL 2000 DB.

We have many querys/SPs running in the main program without any problems,
but I also have a procedure which triggers a thread.

Within this thread I CoInitialise(COINIT_MULTITHREADED),dynamicaly create a
ADO connection, assign the ConnectionString, Create a ADOQuery, assign the
SQL text and then run. The running of the Query is done within a Critical
Section.  All this is within a try finally loop - the finally section Closes
then Frees the Connection & Query.  It also UnCoInitialises.

When these threads run, they fail and are imediatly re-tried.  They always
succeed the second try.  I get the following error message:

....EoleException with message '[DBNETLIB][ConnectionRead(WrapperRead()).]
General Network Erro.  Check your documentation'.  Process Stopped.......

Can anybody shed any light on how to cure this error.

Many Thanks in advance

Tim Bailey (iDOiNK Technologies)

Re:Threaded ADO Connections


Justin,

I didn't have any problems until we started running ADO2.6 with SQL2000.
I'm thinking it has something to do with oledb. Did you test "my way" (!)
with these components?

I'll try using a DM and see if that works.

Thanks for your help,

Tim Bailey (iDOiNK Technologies)

Quote
"Justin Pitts" <jpi...@cnstores.com> wrote in message

news:3ab26497$1_2@dnews...
Quote
> Just curious, why do you wrap the query open in a crit section?

> ...anyway, here's how I do threaded ADO:

> drop the requisite objects on a TDataModule - TADOConnection, TADOQuery,
> etc.
> make sure everything works there - test connection at design time, etc.

> create the datamodule dynamically, in the thread, after CoInit.
> Open the connection
> run the query.
> do stuff.
> close conn
> free the Datamodule
> CoUninit.

> Thing is, I've done it your way*, and it works fine. Have you tried the
> TCP/IP network library option for the ADOConnection?

> *Only on NT4SP3+ or Win2k

Other Threads