Link to home
Start Free TrialLog in
Avatar of Ktoshni
KtoshniFlag for Malta

asked on

BDE Engine Exception Handling

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.
ASKER CERTIFIED SOLUTION
Avatar of viktornet
viktornet
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of vladika
vladika

I think Ktoshni want error's reason, not common phrase 'Ops DB Error'
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
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
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;
Sorry....My query didn't work and I must have sent all those messages...sorry...

Regards,
Viktor Ivanov