DAO itself is not multithreaded, so you can't use the MFC DAO classes in multiple threads. Confine your DAO code to a single thread of execution. Otherwise, look for some other thread-safe database operations.
More ideas regarding this question.
As MFC document stated, the DAO classes are not thread safe. I thought probably finish the coding of your application and have tons of code there already, and don't have enough time to change to another database
classes. So you really want to use DAO in your multi-thread application, there is a solution for you.
And you should remember that this is not a true multithread database access, the Jet will serialize the database function calls. In order to operate the database using DAO in different threads, you have to create its own CDaoDatabase and CDaoRecordset instance in each thread.
1. declare a global instance of critical section
CCriticalSection g_CS;
2. In your thread function
// prevent multi-threads initialize the DAO simultaneously
// it will be unlocked when out of scope
CSingleLock lock(&g_CS, TRUE);
// initialize DAO support of MFC
AfxDaoInit();
// initialize your Dao classes here
CDaoDatabase db;
CMyDaoRecordset rs( &db );
// Open the database and recordset
.....
lock.Unlock(); // free lock to let other threads use Dao
///////////////////////////////////////////
// your database operation goes here
// when you doing this, you don't have to lock other threads
.............................
///////////////////////////////////////////
// After you finish the database operation
// lock again and close your recordset and database
lock.Lock();
rs.Close();
db.Close();
return;
3. In your CApp::ExitInstance(), add these two lines
AfxDaoInit();
AfxDaoTerm();
Hope this will help you.