Page 1 of 1

OnDeleteError with TMyQuery

Posted: Thu 22 May 2008 14:27
by jkuiper_them
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?

Posted: Mon 26 May 2008 14:33
by Dimon
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.

Posted: Tue 27 May 2008 13:49
by jkuiper_them
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?

Posted: Tue 27 May 2008 14:17
by jkuiper_them
Problem solved.

Code: Select all

EMyError(E)

Posted: Wed 28 May 2008 10:30
by Dimon
It is good to see that this problem has been solved.