I'm migrating a vc6.0 code base to vs 2008. MS Access database is used. while trying to open mdb file CRecordset's Open is throwing Exception (Too few parameters. Expected 4).
int CDB::OpenConnection(CString strDSN, CString& strErr)
m_pPointSet = new CPointSet(&m_Database);
m_pGlobalSet = new CGlobalSet(&m_Database);
m_pFormulaSet = new CFormulaSet(&m_Database);
if(!m_pEbExportSet->Open())
{
TRACE("*********DB's Connec Error Code in EbExportSet Open : %d", DB_CONNECTION_ERROR);
return DB_CONNECTION_ERROR;
}
else
{
TRACE("**************No Exception " );
}
if(!m_pFormulaSet->Open())
{
TRACE("*********DB's Connec Error Code in FormulaSet Open : %d", DB_CONNECTION_ERROR);
return DB_CONNECTION_ERROR;
}
else
{
TRACE("**************No Exception " );
}
if(!m_pGlobalSet->Open())
{
TRACE("*********DB's Connec Error Code in GlobalSet Open : %d", DB_CONNECTION_ERROR);
return DB_CONNECTION_ERROR;
}
else
{
TRACE("**************No Exception " );
}
}
CATCH_ALL( e )
{
LPTSTR lpErr = strErr.GetBuffer(255);
e->GetErrorMessage(lpErr, 255);
strErr.ReleaseBuffer();
TRACE("Error String : %s ", strErr);
LogException(strErr, "OpenConnection");
TRACE("................logged.............\n");
return DB_EXCEPTION;
}
END_CATCH_ALL
return SUCCESS;
}
m_pEbExportSet, m_pFormulaSet, m_pGlobalSet are objects of class derived from CRecordset. Only m-pGlobalset->Open() is throwing exception, remaining is working fine.
The Exception is thrown after coming out of CGlobalSet:oFieldExchange(CFieldExchange* pFX).
But this Open() is working fine in VS2008 environment (ie when I execute using Ctrl+F5 or F5), but after building when I run exe its not working!
Re: Why my CRecordset::Open is throwing Exception?
First, please use code tags when posting code. The code is unreadable and unformatted, which is probably the reason why no one has responed to you.
Secondly, you have all of these classes derived from CRecordSet, but we have no idea if you did anything in these classes to cause the issue. You should post your code for these classes.
Third, you can just debug a release build by changing compiler options to include debugging info. Since the problem appears in the release version, then that is what you should try to do.
MoveFirst();
while (!IsEOF())
{
nCount ++;
MoveNext();
}
MoveFirst();
return nCount;
}
// please open the recordset again, it is closed if fails to requery
int CGlobalSet::RequeryFail()
{
if (!IsOpen())
{
m_strFilter.Empty(); // clear the filter, then open
if (!Open())
{
TRACE("**********************DB Connection Error -99******************");
return DB_CONNECTION_ERROR;
}
}
TRACE("**********************DB Query Error -97******************");
return DB_QUERY_ERROR;
}
Bookmarks