YourDbFunction()
{
  CCriticalSection  criSection; // 保护数据库操作的代码段!  criSection.Lock();  connectptr-> ...
  ..... criSection.Unlock();}