ta*******@gmail.com wrote:
Hi all.
I'm writting a multithreading program that will update a loacal Access
database.
I'm using OleDB connection to get access to the database from each
thread and my question is: how do I synchronize between threads\ how do
I lock the database so no clashes between threads occurs.
do I have to use a diffrent connection\adapters???
No provider will handle issues like that for you. There are many things
you could (or should) do if the threads are trying to update the same
data simultaneously:
-Keep track of what the threads are updating (sync'ing - not gonna get
in the deep details or how-to's here; there's various ways to sync
threads and such, well documented, and it tends to get a bit
complicated), also to minimize deadlocks and such
-Have code to handle the concurrency issues (it WILL happen no matter
how careful you are)
-Make sure you're using the optimal lock type
-Commit transactions to DB as quickly as possible (not lock things for a
long time) - MANY things you can do for this alone...
-perhaps use a better database - access isn't exactly a great db, but
this is one of those scenarios where it's especially lacking (several
concurrent connections, transactional/high integrity, heavy stress/load,
may need to scale significantly, need to minimize "locking time" and
query execution time, etc). Honestly, I'd look into SQL Server Express
or any other real RDBMS like PostgreSQL. Perhaps that's the very first
thing I would change, it's definitely not helping.
and I'm sure many many more things could be said about it, but that's a
good start.