Solved

Trapping EOLEException exceptions

Posted on 2000-03-23
6
417 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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

757 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now