Board index » delphi » Ado, Threads (and videotape)

Ado, Threads (and videotape)


2005-03-16 07:14:20 PM
delphi201
Ado, Threads (and videotape)
The idea is this.
I have an object whose properties can be written and read form different
threads.
I protect the attributes with a TMultiReadExclusiveWriteSynchronizer.
The thing is that i want some of these attributes be persistent in a Access
BD (using ADO). I'd like the object to write in the BD, within the
SetValue functions of his properties.
But doing this, I write in the BD within the context of the threads, and any
of the thread should have his own ADOConnection. Shouldn't it?
So How could I use those different ADOConnection within the SetValue of the
property??? Any ideas ???
I have this working with one ADOConnection and using transactions, but don't
seems to be the better way
thanksssss
 
 

Re:Ado, Threads (and videotape)

Hi,
"Josu Z." <XXXX@XXXXX.COM>escribi?en el mensaje
Quote
Ado, Threads (and videotape)
I have an object whose properties can be written and read form different
threads.

I protect the attributes with a TMultiReadExclusiveWriteSynchronizer.

The thing is that i want some of these attributes be persistent in a
Access BD (using ADO). I'd like the object to write in the BD, within
the SetValue functions of his properties.

But doing this, I write in the BD within the context of the threads, and
any of the thread should have his own ADOConnection. Shouldn't it?
No. You can have only one TADOConnection for it. Having multiple
TADOConnections has sense, for example, if you need to connect to multiple
databases and don't want to change the ConnectionString, but not for
threads.
IMO it is better to use a TCriticalSection or equivalent to assure that only
one thread is accessing to the TADOConnection. Also, on threads don't forget
to use CoInitialize before you use any ADO component and Couninitialize
after using it.
--
Best regards :)
Guillem Vicens
Dep. informática Green Service SA
XXXX@XXXXX.COM
www.clubgreenoasis.com
 

Re:Ado, Threads (and videotape)

"Guillem" <XXXX@XXXXX.COM>escribi?en el mensaje
Quote

No. You can have only one TADOConnection for it.
Sorry, i wanted to write that you can have one, but that does not exclude to
have more
 

Re:Ado, Threads (and videotape)

Thank you very much Guillem!!!!!!!!