I just switched from using the BDE to ADO by replacing the Tables and Queries to its equivalent in ADO components.
I'm always execute the query inside try...catch like this:
//Fdm is Data Module
//TEndOfDay is TTable
//QEndOfDay is TQuery
Screen->Cursor = crSQLWait;
Fdm->QEndOfDay->SQL->Add("SELECT * FROM TEndOfDay");
try{
Fdm->QEndOfDay->ExecSQL();
Fdm->QEndOfDay->Open();
Screen->Cursor = crDefault;
}
catch (EDBEngineError &DBEngineError){
strError = DBEngineError.Message;
Screen->Cursor = crDefault;
}
catch (EDatabaseError &DatabaseError){
strError = DatabaseError.Message;
Screen->Cursor = crDefault;
}
catch(...){
strError = "Error";
Screen->Cursor = crDefault;
}
Since I switched to ADO, does those exceptions (DBEngineError, DatabaseError) are applicable?
I have been edited my post to include Delphi folks, they are responds quickly. No matter if the answer in Delphi code.
You should first check for
EADOError, which are specific ADO-related exceptions, and thenEDatabaseError, which are more general database exceptions.EDBEngineErroris an old BDE exception class, and is not applicable any longer if you're not using the BDE.