Link to home
Create AccountLog in
Avatar of mh_attar
mh_attar

asked on

using CDataBase in a multithreaded app.

I want to use ODBC in a multithreaded application.Should I worry about simultanios access to record or ODBC itself manages it (by some sort of locking)? In other words should I use critical sections , etc when updating the database or executing a query ?
Avatar of ghimireniraj
ghimireniraj

you must if you want proper data manipulation or retrieval unless you are sure about the exact sequence of the threads accessing the database

ghimireniraj
If you are using DAO, it's not good idea. DAO don't support multiread/multiwrite actions.
If you use DAO, you have to create a critical section to regulate the thread access to database.
You can use ADO. It support multiread/multiwrite actions.


I hop that you resolve your problem.

Have a lot of fun!
Avatar of mh_attar

ASKER

My question was about MFC’s ODBC database classe(CDatabase,CRecordset,..)
and not DAO classes(CDaoDatabase , CDaoRecordest,...).
MFC's ODBC classes are thread-safe
You can use CDatabase and Crecordset classes in any app threads without worrying about simultaneous access.

ASKER CERTIFIED SOLUTION
Avatar of mikeblas
mikeblas

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer