EricNielsen
May 5th, 1999, 11:10 AM
I have an application in which my class runs a database
analysis. One of the my class members is a CDaoDatabase
object. In my analysis method I retrieve the active
database name as follows:
CString dbPath = m_db.GetName();
My problem: When I run this analysis method from the
main thread everything works just fine. But, when I
run it in a worker thread (which is what I want to do!)
I get an exception:
DAO350.DLL: 0xC0000005: Access Violation
I have traced the code in the debugger, and all the
CDaoDatabase members are EXACTLY the same whether in the
main thread or a worker thread. Anyone have any ideas on
why the CDaoDatabase::GetName() method fails when called
in the worker thread?
Below is the code from ..\Vc\mfc\src\Daocore.cpp. I have
indicated the line of code which fails.
Any enlightenment would be greatly appreciated!!
Eric
=========================================================
CString CDaoDatabase::GetName()
{
ASSERT_VALID(this);
ASSERT(IsOpen());
ASSERT(m_pDAODatabase != NULL);
COleVariant var;
//<< Blows up on the following statement >>
DAO_CHECK(m_pDAODatabase->get_Name(&V_BSTR(&var)));
var.vt = VT_BSTR;
return V_BSTRT(&var);
}
Eric
analysis. One of the my class members is a CDaoDatabase
object. In my analysis method I retrieve the active
database name as follows:
CString dbPath = m_db.GetName();
My problem: When I run this analysis method from the
main thread everything works just fine. But, when I
run it in a worker thread (which is what I want to do!)
I get an exception:
DAO350.DLL: 0xC0000005: Access Violation
I have traced the code in the debugger, and all the
CDaoDatabase members are EXACTLY the same whether in the
main thread or a worker thread. Anyone have any ideas on
why the CDaoDatabase::GetName() method fails when called
in the worker thread?
Below is the code from ..\Vc\mfc\src\Daocore.cpp. I have
indicated the line of code which fails.
Any enlightenment would be greatly appreciated!!
Eric
=========================================================
CString CDaoDatabase::GetName()
{
ASSERT_VALID(this);
ASSERT(IsOpen());
ASSERT(m_pDAODatabase != NULL);
COleVariant var;
//<< Blows up on the following statement >>
DAO_CHECK(m_pDAODatabase->get_Name(&V_BSTR(&var)));
var.vt = VT_BSTR;
return V_BSTRT(&var);
}
Eric