?
Solved

BDE Engine Exception Handling

Posted on 1998-09-08
6
Medium Priority
?
638 Views
Last Modified: 2013-11-23
I'm new to Delphi (Using Delphi 1) and I am experimenting with the BDE engine on an Interbase Local Server. My question is how do I use the EDBENGINEERROR exception handler properly so as catch the reason for any errors to be displayed in a dialog box. The on-line help is not very clear about this.
0
Comment
Question by:Ktoshni
  • 5
6 Comments
 
LVL 10

Accepted Solution

by:
viktornet earned 100 total points
ID: 1338984
begin
  ///some code or maybe not
  try
    ///some more code
  except on EDBENGINEERROR
    ShowMessage('Ops DB Error');
  end;
end;

Regards,
Viktor Ivanov

0
 
LVL 3

Expert Comment

by:vladika
ID: 1338985
I think Ktoshni want error's reason, not common phrase 'Ops DB Error'
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1338986
Ok, here is a snippet from the help file,,,,
------------
The E parameter is usually of type EDBEngineError. From this exception type, you can extract an error message that you can display to users in your error handler. For example, the following code could be used to display the error message in the caption of a dialog box:

ErrorLabel.Caption := E.Message;

This parameter is also useful for determining the actual cause of the update error. You can extract specific error codes from EDBEngineError, and take appropriate action based on it. For example, the following code checks to see if the update error is related to a key violation, and if it is, it sets the UpdateAction parameter to uaSkip:

{ Add 'Bde' to your uses clause for this example}
if E is EDBEngineError then
 with EDBEngineError(E) do
 begin
   if Errors[ErrorCount - 1].ErrorCode = DBIERR_KEYVIOL then
     UpdateAction := uaSkip  { Key violation, just skip this record }
   else
     UpdateAction := uaAbort { Don't know what's wrong, abort the update }
 end;
---------------
Regards,
Viktor Ivanov
0
Independent Software Vendors: 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 10

Expert Comment

by:viktornet
ID: 1338987
Ok, here is a snippet from the help file,,,,
------------
The E parameter is usually of type EDBEngineError. From this exception type, you can extract an error message that you can display to users in your error handler. For example, the following code could be used to display the error message in the caption of a dialog box:

ErrorLabel.Caption := E.Message;

This parameter is also useful for determining the actual cause of the update error. You can extract specific error codes from EDBEngineError, and take appropriate action based on it. For example, the following code checks to see if the update error is related to a key violation, and if it is, it sets the UpdateAction parameter to uaSkip:

{ Add 'Bde' to your uses clause for this example}
if E is EDBEngineError then
 with EDBEngineError(E) do
 begin
   if Errors[ErrorCount - 1].ErrorCode = DBIERR_KEYVIOL then
     UpdateAction := uaSkip  { Key violation, just skip this record }
   else
     UpdateAction := uaAbort { Don't know what's wrong, abort the update }
 end;
---------------
Regards,
Viktor Ivanov
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1338988
Ok, here is a snippet from the help file,,,,

The E parameter is usually of type EDBEngineError. From this exception type, you can extract an error message that you can display to users in your error handler. For example, the following code could be used to display the error message in the caption of a dialog box:

ErrorLabel.Caption := E.Message;

This parameter is also useful for determining the actual cause of the update error. You can extract specific error codes from EDBEngineError, and take appropriate action based on it. For example, the following code checks to see if the update error is related to a key violation, and if it is, it sets the UpdateAction parameter to uaSkip:

{ Add 'Bde' to your uses clause for this example}
if E is EDBEngineError then
 with EDBEngineError(E) do
 begin
   if Errors[ErrorCount - 1].ErrorCode = DBIERR_KEYVIOL then
     UpdateAction := uaSkip  { Key violation, just skip this record }
   else
     UpdateAction := uaAbort { Don't know what's wrong, abort the update }
 end;
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1338989
Sorry....My query didn't work and I must have sent all those messages...sorry...

Regards,
Viktor Ivanov
0

Featured Post

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!

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Suggested Courses
Course of the Month17 days, 10 hours left to enroll

829 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