Solved

BDE Engine Exception Handling

Posted on 1998-09-08
6
620 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
[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
  • 5
6 Comments
 
LVL 10

Accepted Solution

by:
viktornet earned 50 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
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!

 
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

Suggested Solutions

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…
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…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
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…

734 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