S
Simon
Hi,
In my C++ code I try and run a query to delete data older than a certain
date.
The query is fairly straight forward.
....
strSQL = "DELETE FROM Log WHERE DateTime < ";
strSQL += dtDelete.Format("#%m/%d/%y %H:%M:%S#");"
....
Where the value dtDelete is a 365 days ago.
I then check that the database is open and that the query does not already
exists.
bool bExists = true;
CDaoQueryDef qdCheck(m_pDaoDatabase);
try
{
qdCheck.Open("logdelete");
}
catch( CDaoException* e )
{
// query does not exist so clear the flag
bExists = false;
e->Delete();
}
....
if it exists remove it, (also surrounded by try/catch(CDaoException* e)
....
try{
CDaoQueryDef query(m_pDaoDatabase);
query.Create("", strQuery);
query.Execute();
query.Close();
}
catch (CDaoException* e)
{
CString strError;
strError = "Could not execute query: ";
strError += e->m_pErrorInfo->m_strDescription;
e->Delete();
return false;
}
return true;
....
But sometimes I get the message "The Microsoft Jet Database Engine could not
find the object "logdelete"..."
Why would that be? How can I prevent the messages from appearing?
Could it be that I need to add a more general try/catch in some cases?
Any ideas?
Simon
In my C++ code I try and run a query to delete data older than a certain
date.
The query is fairly straight forward.
....
strSQL = "DELETE FROM Log WHERE DateTime < ";
strSQL += dtDelete.Format("#%m/%d/%y %H:%M:%S#");"
....
Where the value dtDelete is a 365 days ago.
I then check that the database is open and that the query does not already
exists.
bool bExists = true;
CDaoQueryDef qdCheck(m_pDaoDatabase);
try
{
qdCheck.Open("logdelete");
}
catch( CDaoException* e )
{
// query does not exist so clear the flag
bExists = false;
e->Delete();
}
....
if it exists remove it, (also surrounded by try/catch(CDaoException* e)
....
try{
CDaoQueryDef query(m_pDaoDatabase);
query.Create("", strQuery);
query.Execute();
query.Close();
}
catch (CDaoException* e)
{
CString strError;
strError = "Could not execute query: ";
strError += e->m_pErrorInfo->m_strDescription;
e->Delete();
return false;
}
return true;
....
But sometimes I get the message "The Microsoft Jet Database Engine could not
find the object "logdelete"..."
Why would that be? How can I prevent the messages from appearing?
Could it be that I need to add a more general try/catch in some cases?
Any ideas?
Simon