OnDeleteError with TMyQuery

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
jkuiper_them
Posts: 28
Joined: Thu 20 Dec 2007 14:48

OnDeleteError with TMyQuery

Post by jkuiper_them » Thu 22 May 2008 14:27

If the database returns an error, I handle it with the OnDeleteError

Code: Select all

procedure TFrm.FunctieAanvraagDeleteError(DataSet: TDataSet;
  E: EDatabaseError; var Action: TDataAction);
begin
  Action := daAbort;
  ShowMessage(E.ClassName+' ERROR : '#13#10+E.Message);
end;
As far as I know, there's a EMyError class, witch gives the exact messages and errornumbers of the MySQL database. But why is OnDeleteError using EDatabaseError. Does it give the same results as EMyError?

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Mon 26 May 2008 14:33

The EMyError class is inherited from the EDatabaseError class.
In the DeleteError event handler you can cast the E object to the EMyError type and use the ErrorCode and Message values to know the exact message and error number.

jkuiper_them
Posts: 28
Joined: Thu 20 Dec 2007 14:48

Post by jkuiper_them » Tue 27 May 2008 13:49

This is working

Code: Select all

procedure TPrintOpdrachtenFrm.BtnDeleteClick(Sender: TObject);
begin
   try
   functieaanvraag.Delete;
   except
   on E : EMyError do
   ShowMessage(inttostr(E.ErrorCode) +'; errormessage found : '+EMyError(E).Message);
   end;
end;
But I can't get it to the OnDeleteError event.
Please, can you give me an example to typcast the E to EMyError instaed of using EDatabaseError?

jkuiper_them
Posts: 28
Joined: Thu 20 Dec 2007 14:48

Post by jkuiper_them » Tue 27 May 2008 14:17

Problem solved.

Code: Select all

EMyError(E)

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Wed 28 May 2008 10:30

It is good to see that this problem has been solved.

Post Reply