Solved

Trapping EOLEException exceptions

Posted on 2000-03-23
6
428 Views
Last Modified: 2010-04-04
How to I trap EOLEException exceptions that occur during OLEDB operations, specifically ADO database methods?

I've tried the standard exception code :
try
 ado.database.commands.here;
except
 on EOLEException do AppException;
end;

This doesn't trap the EOLEException, or at least suppress it.

What I'm loooking for is a way to suppress the program displaying the EOLEException message.

Any ideas?
0
Comment
Question by:ray_leach
  • 3
  • 2
6 Comments
 
LVL 2

Expert Comment

by:florisb
ID: 2648839
in formcreate:
application.OnException := myError;
end;

procedure TForm1.myError(Sender: TOBject; Error: Exception);
begin
screen.cursor := crDefault;
ShowMessage('An error....;-(');
end;
0
 
LVL 13

Accepted Solution

by:
Epsylon earned 120 total points
ID: 2648969
Your code should trap that exception but not when you run it inside the Delphi debugger. Run the app as stand-alone and see what happens.

Use this to test it:

var ADOTable1: TADOTable;
begin
  try
    ADOTable1.First;
  except
    ShowMessage('Trapped');
  end;
end;


But Florisb's example should work too.
0
 
LVL 2

Author Comment

by:ray_leach
ID: 2649329
Adjusted points from 100 to 120
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Author Comment

by:ray_leach
ID: 2649330
Thanks guys, but I've already got that and what happens is the exception is raised before my handler is called.

Is there something that I'm missing.

Below is my code:

type
  TfrmSetup = class(TForm)
....
....
public
    { Public declarations }
    procedure AppException(Sender: TObject; E: Exception);
end;

....
....

procedure TfrmSetup.FormCreate(Sender: TObject);
var
  Reg   : TRegistry;
begin
  Application.OnException := frmSetup.AppException;
....
....
end;

....
....
try
    BuildAccessDB(Self);
  except
    on E : EOleException do AppException(Self,E);
  end;
....

This handler is not called until after the exception is displayed, which is not what the help pages say. The help says that the ShowException method will be called unless an OnException event handler is declared ...

0
 
LVL 13

Expert Comment

by:Epsylon
ID: 2649432
Run it outside Delphi! Delphi always raises the exceptions, no matter what you do.
0
 
LVL 2

Author Comment

by:ray_leach
ID: 2652133
Thanks guys!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question