Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to catch EDBEngineError 1

Status
Not open for further replies.

RSi2

Programmer
Jul 22, 2002
91
FR
i have a TDataBase component that should connect to a SQL server via ODBC.
i disconnected the network cable, and tried to catch the EDBEngineError to do some treatment.

try
myDatabase.Open;
except
on EDBEngineError do BlaBlaBla;
end;

it never executes the BlaBlaBla stuff ... and the error isn't caught ... i can still see the error message window ... an EDBEngineError has occured ...

10x, RSi2
 
i managed to make delphi execute the BlaBlaBla, but i still have the error window ... how can i disable/kill it ?
 
Try adding Application.OnException handler. It can look like this:
Code:
procedure TfrMain.DBException(Sender: TObject; E: Exception);
begin
  if E.ClassType = EIBInterBaseError then // change "EIBInterBaseError" to the Class type you need.
  begin
    if Pos('Unable to complete network request to host', E.Message) <> 0 then
    begin
      MessageDlg('Connection lost. Please restart the program!',mtError,[mbOk],0);
      ExitProcess(0);
    end;
  end
  else
   MessageDlg(E.ClassName + ' ' + E.Message, mtError,[mbOk], 0);
end;
And in your main form OnCreate event add:
Code:
procedure TfrMain.FormCreate(Sender: TObject);
begin
...
  Application.OnException := DBException;
...
end;
Hope that helps.

--- markus
 
The error is intercepted by the handler ... same as try ... except.
BUT is still get a window with The Project.exe has triggered a EDBEngineError exception class
 
LOL, that happend only in Delphi, if i use directly the EXE, no more unwanted error msg :)))
 
Then go to Tools/Debugger options/Language exception and uncheck &quot;Stop on Delphi exceptions&quot;.

--- markus
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top