Get error message or exception using ExecuteDirect (Zeos components) lazarus / 16-Databases ---------------------------------------------------------------------- derles · 2013-07-11 16:32 Hello. I´m using Lazarus and Firebird, with Zeos components. 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). 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. ---------------------------------------------------------------------- garlar27 · 2013-07-11 17:17 ExecuteDirect is way much faster than ExecSQL. And yes, it don't tell you what error happened. what I do is this: Code: [Select]if not zConnection.ExecuteDirect(sQ) then    try         zQuery01.SQL.Add(sQ);// <---   THIS IS FASTER THAN zQuery01.SQL.Text:= sQ;         zQuery01.ExecSQL;         Result := True;    except         on E:Exception do         begin             Result := False;             ShowMessage('An error occurs: '+E.Message);         end;    end; ---------------------------------------------------------------------- derles · 2013-07-11 18:37 I see. Ok garlar, I probably adopt your code in my function.  Thank you. ---------------------------------------------------------------------- garlar27 · 2013-07-11 20:08 Quote from: derles on July 11, 2013, 08:37:04 pmI see. Ok garlar, I probably adopt your code in my function.  Thank you. Although it would be nice to know if there is a better solution...