[SOLVED] Problem with try except lazarus / 16-Databases ---------------------------------------------------------------------- melwinek · 2015-04-25 08:51 I want to handle the exception of duplicate key. ............... try   SQL.ExecSQL; except    on E: EDatabaseError do      ShowMessage(E.Message); end; First I get my message from ShowMessage. Then the standard message: "PQConnection1: Preparation of query failed.........Press OK to ignore and risk data corruption. Press Cancel to kill the program." How to eliminate standard message? ---------------------------------------------------------------------- totya · 2015-04-25 09:18 Code: [Select]try   SQL.ExecSQL; except    on E: EDatabaseError do ShowMessage(E.Message);    on E: Exception do; // if you want to hide this error message really... end; ---------------------------------------------------------------------- LacaK · 2015-04-25 15:43 EPQDatabaseError which is raised by TPQConnection is descendant of EDatabaseError, so it should be handled by:   on E: EDatabaseError do I do not understand why error message is displayed twice: - first by ShowMessage - second standard error handling ---------------------------------------------------------------------- Leledumbo · 2015-04-25 16:56 Sample project required. Exception that has been handled won't return. i.e. if EDatabaseError (or its descendants) is raised by ExecSQL and handled by on e: EDatabaseError, then after that, normal program flow continues. The second one must be triggered by another thing, could be the same method, I don't know as I can't see the complete code. ---------------------------------------------------------------------- melwinek · 2015-04-28 09:24 Quote from: totya on April 25, 2015, 11:18:46 amCode: [Select]try   SQL.ExecSQL; except    on E: EDatabaseError do ShowMessage(E.Message);    on E: Exception do; // if you want to hide this error message really... end; Thank you very much. It works.