Strange Problem when closing the database object
Hi All,
I have a COM component using which is interacting with the database
using the CDAODATABASE class. my applications works fine when i built
it with VS6. when i built the application with VS2005, the application
is suddently unloaded when i am trying to close the database.
my database object is
CDaoDatabase *m_DB;
when my application calls the following method the component is
getting unloaded.
STDMETHODIMP CFeatureTable::Close()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
HRESULT hRes = S_OK;
if (!m_Initialized)
return S_OK;
TRY_DAO
{
// Need to rollback the current transaction to prevent
// nested transactions (limited to 5 for a workspace).
if (m_TransactionOpen && m_DB->m_pWorkspace->IsOpen())
{
m_DB->m_pWorkspace->Rollback();
m_TransactionOpen = FALSE;
m_DB->m_pWorkspace->Close();
}
// Update everything first.
m_pFeature->Close();
if (m_CategoryRec->IsOpen())
{
if (m_CategoryRec->GetEditMode() != dbEditNone)
m_CategoryRec->Update();
m_CategoryRec->Close();
}
if (m_DB->IsOpen())
m_DB->Close(); /* i am getting the problem at this line.*/
}
CATCH_DAO_EXCEPTION;
delete m_TmpFeatureRec;
delete m_TmpFeatureExRec;
delete m_MSCatalogRec;
delete m_CategoryRec;
delete m_DB;
m_TmpFeatureRec = NULL;
m_TmpFeatureExRec = NULL;
m_MSCatalogRec = NULL;
m_CategoryRec = NULL;
m_DB = NULL;
return hRes;
}
I am gettting the problem at the following line
if (m_DB->IsOpen())
m_DB->Close();
i found this is occuring only in release mode. In debug mode the
application is working fine.
The surprising part is the application is working fine in debug mode
when built in VS6 and VS2005. It is giving problem only when it is
built in release mode in VS2005.
Can any one give me some suggestions to resolve this issue?
Thanks in advance,
suneel