Page 1 of 1

Capture SQL error

Posted: Sat 18 Apr 2015 20:09
by nszmnsky
I'm using LiteDAC's LiteSQL component to run SQLs to make database updates and have code set to rollback if an error occurs using try..except blocks. That seems to be working well, but I'd also like to capture what the SQL error was but can't find anything that appears to be the error. Is there a way, with LiteSQL or another LiteDAC component, to capture what caused the SQL failure?

Re: Capture SQL error

Posted: Mon 20 Apr 2015 10:58
by AlexP
Hello,

You can use the onError event of the LiteConnection component and the ESQLiteError class:

Code: Select all

uses ..., LiteError;
...
procedure TForm1.LiteConnection1Error(Sender: TObject; E: EDAError;
  var Fail: Boolean);
begin
  ShowMessage(ESQLiteError(E).Message);
end;