rollback applyupdates? lazarus / 16-Databases ---------------------------------------------------------------------- mangakissa · 2017-02-16 15:54 For capturing the errormessage I use these lines of codes: 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 TDMNAW.SQLnawAfterDelete(DataSet: TDataSet);var MyQuery : TSQLQuery;begin  try    MyQuery := TSQLQuery(dataset);    MyQuery.ApplyUpdates;    TSQLtransaction(TsqlQuery(Dataset).Transaction).CommitRetaining  except    showmessage('Record can not removed. Is related to another table');  end;end;                  But when I refresh my records in dataset, my applications complains about the changes that have to applied with procedure applyupdates(). But applyUpdates() to to delete the record which is impossible by relation. Is there a way to rollback the applyupdates() so a refresh can be done? Application is build on lazarus 1.6.2 / FPC 3.0 Windows ---------------------------------------------------------------------- mangakissa · 2017-02-16 16:04 This works: 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     MyQuery.Close;    MyQuery.Open; But is this not the same as Myquery.refresh? ---------------------------------------------------------------------- balazsszekely · 2017-02-16 16:08 Use the RollbackRetaining method. 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 TDMNAW.SQLnawAfterDelete(DataSet: TDataSet);var MyQuery : TSQLQuery;begin  try    MyQuery := TSQLQuery(dataset);    MyQuery.ApplyUpdates;    TSQLtransaction(TsqlQuery(Dataset).Transaction).CommitRetaining   except    TSQLtransaction(TsqlQuery(Dataset).Transaction).RollbackRetaining;    showmessage('Record can not removed. Is related to another table');  end;end; ---------------------------------------------------------------------- mangakissa · 2017-02-17 14:59 Getmem, I allready tried, but doesn't work. It comes with message QuoteMust apply updates before refreshing data. It's logical. Internally the dataprovider of SQLdb has still a flag that notice a change in the dataset. That's the problem. ---------------------------------------------------------------------- balazsszekely · 2017-02-17 15:19 QuoteGetmem, I allready tried, but doesn't work. It comes with messageThen just before RollbackRetaining do a MyQuery.Cancel or MyQuery.CancelUpdates. ---------------------------------------------------------------------- fpcoder · 2017-02-20 16:53 Have had the same question, why you have to open/close to refresh. Now I got this idea that TSQLQuery has a property called RefreshSQL and if its empty, maybe thats why it doesn't work just calling refresh. Haven't tested, but you could try add some code to RefreshSQL and see if a plain call to Refresh works after that. Quote from: mangakissa on February 16, 2017, 05:04:09 pmThis works: 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     MyQuery.Close;    MyQuery.Open; But is this not the same as Myquery.refresh? ---------------------------------------------------------------------- LacaK · 2017-02-21 17:39 Intention of RefreshSQL is update local buffered record after update of record has been applied to database (ukInsert or ukModify). If database table has some generated columns (as default or auto- increment or set by triggfer) then these new values are re-fetched and local record is refreshed. RefreshSQL has no relation to TSQLQuery.Refresh but to TSQLQuery.ApplyUpdates