Board index » delphi » BDE to ADO on am mutlithreaded app w/sessions (ADO newbie)

BDE to ADO on am mutlithreaded app w/sessions (ADO newbie)

I have a fairly big app (200000 lines) connecting to Access DB via BDE.
It is a multi threaded app with one TSession for each thread, managing the
DB connections.
I want to move this over to SQL Server and ADO but my concern are theses
TSessions and the mutli-thread.
Do I have to do something special for ADO to handle the multiple threads and
then what ???

All help kindly appreciated.

Thanks

 

Re:BDE to ADO on am mutlithreaded app w/sessions (ADO newbie)


Each thread gets it's very own TADOConnection, and each thread must call
CoInitializeEx before using ADO, and must call CoUnInitialize before
exiting.

eg:

procedure TMyThread.Execute;
begin
    CoInitializeEx(nil, 2)
    try
        DoADOStuff;
    finally
        CoUnInitialize;
    end;
end;

ADO threads quite well, and don't be alarmed when you see a new thread suck
up a few meg of memory - ADO can be like that. I'm doing the same - ADO to
SQL Server - and it works great for me.

Re:BDE to ADO on am mutlithreaded app w/sessions (ADO newbie)


Quote
>I want to move this over to SQL Server and ADO but my concern are theses
>TSessions and the mutli-thread.
>Do I have to do something special for ADO to handle the multiple threads and
>then what ???

Just make sure you create any components you use for the ADO connection inside
the thread.   You can just create a new instance of your datamodel if it has
everthing you need.

--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

Other Threads