Solved

Trapping EOLEException exceptions

Posted on 2000-03-23
6
431 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Suggested Solutions

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

739 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