Page 1 of 1

ExecuteDirect: where to read error message ?

Posted: 11.07.2013, 17:28
by derles
Hello.

I?m using Zeos with Lazarus and Firebird.

When I needed to execute an INSERT, UPDATE or DELETE sentence, I usually used a ZQuery component, with the ExecSQL method.
As in this code portion: (sQ variable contains mi SQL sentence).

Code: Select all

try
     zQuery01.SQL.Text:= sQ;
     zQuery01.ExecSQL;
     Result := True;
except
     on E:Exception do
     begin
         Result := False;
         ShowMessage('An error occurs: '+E.Message);
     end;
end;
Now I'm trying to use ZConnection.ExecuteDirect instead ZQuery.ExecSQL. It looks simplier.
But the problem I find is this: when the sql sentence was not succesful (syntax error, or PK duplicates o something else), I don't know how to capture the error to show the error message.
I mean: the ExecuteDirect returns False, but I think no exception is thrown. Is this correct? So, where can I find the error message returned? is this possible?

Thanks.