TSQLQuery.UpdateStatus lazarus / 16-Databases ---------------------------------------------------------------------- Gunter · 2014-07-11 18:36 Hi! I use Lazarus 1.2.2, FPC 2.6.4 in WinXP. Database SQLite3. The problem is that I do not manage to catch the usDeleted status of TSQLQuery. When adding or changing a record is no problem, the status dataset, as expected, returns usInserted, usModified. When I click on the Delete button and confirm the deletion of an entry, entry of the grid disappears. I expect status usDeleted, but the status of the dataset returned usUnmodified. I can not understand why this happens. Tell me, please, how to determine the status of TSQLQuery, when the record is deleted. My code example Code: [Select]procedure TForm1.dbnav1Click(Sender: TObject; Button: TDBNavButtonType); begin   if button = nbDelete then   begin     case qry1.UpdateStatus of       usUnmodified : ShowMessage('Unmodified');       usModified   : ShowMessage('Modified');       usInserted   : ShowMessage('Inserted');       usDeleted    : ShowMessage('Deleted');     end;   end; end; ---------------------------------------------------------------------- jdlinke · 2014-07-11 23:36 Looks like others have had similar questions. One suggested solution HERE is: Quote Set the ClientDataSet.StatusFilter to an TUpdateStatus value, and then read ClientDataSet.RecordCount for example, Code: [Select] ClientDataSet1.StatusFilter := [usDeleted];  ShowMessage(IntToStr(ClientDataSet1.RecordCount)); will return the number of Delete queries that will be executed. Note two things, however. Setting StatusFilter to usModified always includes both the modified and unmodified records, so you take half of that value (a value of 4 means 2 Update queries will be executed). Also, setting StatusFilter to [] (an empty set) is how you restore to default view (Modified, Unmodified, and Inserted) Make sure that any unposted changes have been posted before doing this, otherwise unposted changes may not be considered. ---------------------------------------------------------------------- Gunter · 2014-07-12 08:07 Jdlinke, thank you very much for your reply. Unfortunately, this does not work in Lazarus, as well as in Delphi. I use TSQLQuery as Dataset. It has no property StatusFilter. ---------------------------------------------------------------------- fpcoder · 2014-07-12 15:24 Dont know for sure if this is what you need, but here's some sample code I wrote while fiddling around. The AfterDelete is used for deleting. For the rest of it, this project was just a test trying to learn this stuff. Its master/detail using a link table, so three tables instead of the usual two. (Later I polished it and made it work with cascading deletes, but that sample is on another computer, not here. Cascading deletes can remove all detail records automatically when the master record is deleted. And only like two lines of code, real simple and very nice to have. If anyone interested, I can see if i find the code). ---------------------------------------------------------------------- Gunter · 2014-07-12 17:08 Kapibara, thanks for the answer. I investigate Lazarus and do not understand some things. Thank you for your example.