Solved

Trapping EOLEException exceptions

Posted on 2000-03-23
6
420 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.
Delivering innovative fully-managed cloud services for mission-critical applications requires expertise in multiple areas plus vision and commitment. Meet a few of the people behind the quality services of Concerto.

911 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

19 Experts available now in Live!

Get 1:1 Help Now