OnPosError doesn't work at all. lazarus / 16-Databases ---------------------------------------------------------------------- mangakissa · 2016-12-29 16:09 I have table with an unique index on it. On my form there's a DBGrid and a datasource. The datasource is linked to a dataset. In my datamodule I triggered a TSQLQuery with event OnPostError. If an error occurs, the user must be noticed and the inserted record must be deleted. I never see the debugger stops on the procedure SQLqueryBeforePost(). Actually I get this message (even when the debugger is set off). QuoteAn error occured while applying the updates in a record: IBConnection1 : Execute :  -attempt to store duplicate value (visible to active transactions) in unique index "I_VERTAALLABELS_OMS". Press OK to ignore and risk data corruption. Press Cancel to kill the program. That's the point my user panic. And its not the right info to do it right. Looked up with rvk noticed these event is much better to use: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TDMVertalingen.SQLVertaallabelsUpdateError(Sender: TObject;  DataSet: TCustomBufDataset; E: EUpdateError; UpdateKind: TUpdateKind;  var Response: TResolverResponse);begin  showmessage(E.Message);end;                     It works half way. The user gets the message the filled in fieldvalue is already used, but doesn't have to abort the program. But the DBGrid has already post the record (but not updated to the database). What's the purpose of OnPostError in TSQLQuery If it will not be triggered at all? Why is the DBGrid still save the record in it's buffer? It looks like it is posted. ---------------------------------------------------------------------- LacaK · 2016-12-30 08:24 Quote from: mangakissa on December 29, 2016, 05:09:06 pmWhat's the purpose of OnPostError in TSQLQuery If it will not be triggered at all? It will be triggered if error hapens during Post operation. (not Berore Post nor After Post) For example it will be triggered when any of required fields is null Quote from: mangakissa on December 29, 2016, 05:09:06 pmWhy is the DBGrid still save the record in it's buffer? It looks like it is posted. Yes , because first is record posted in local buffered dataset and only when ApplyUpdates is called is record update send to database, which generates exception. In this case you must use OnUpdateError ---------------------------------------------------------------------- mangakissa · 2016-12-30 09:37 I noticed that. But Do I have to manually delete the record in Grid? OnUpdateEroor is only for the database itself. ---------------------------------------------------------------------- Thaddy · 2016-12-30 10:37 Quote from: mangakissa on December 30, 2016, 10:37:50 amI noticed that. But Do I have to manually delete the record in Grid? OnUpdateEroor is only for the database itself. The grid needs either a fresh connection in the case of a major error or - if you are lucky - just a repaint. You do not have to manually delete it, but you need some knowledge how databases actually work. ---------------------------------------------------------------------- mangakissa · 2016-12-31 09:07 I work for many years now with databases. It seems the OnupdateError has nothing to do with the grid. Al I want is if an error from the database occurs, the record in de the bufdataset will not be post. Now it is and gives a redundancy and a refresh is only a workaround. I shall handle it myself. But it is not nice to get information from the datbase with doing something the the local buffered dataset.