SQLite Query Post Commit lazarus / 16-Databases ---------------------------------------------------------------------- schand99 · 2020-02-10 12:25 Hello, on a existing project which uses SQLite db, I try to replace some database.executedirect by a simple post & commit. I like to do this, because for executedirect, exclusive access to the database is needed. Unfortunately, I am not able to set the Software to work, after writing the data, post and commit, there is no data written. For easier Code parsing, I have copied the following Code snippet and modified as needed, but it did not work. I don't get any error but the data is not saved 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  Program EditData; {$mode objfpc} {$ifdef mswindows}{$apptype console}{$endif} uses     db, sqldb, sqlite3conn; var   AConnection : TSQLConnection;   ATransaction : TSQLTransaction;   Query : TSQLQuery; begin   AConnection := TSQLite3Connection.Create(nil);   ATransaction := TSQLTransaction.Create(AConnection);   AConnection.Transaction := ATransaction;   AConnection.DatabaseName := 'test_dbase';   Query := TSQLQuery.Create(nil);   Query.DataBase := AConnection;   Query.SQL.Text := 'select * from tblNames where ID = 2';   Query.Open;   Query.Edit;   Query.FieldByName('NAME').AsString := 'Name Number 2';   Query.Post;   Query.Upda]"]>Blockedde := upWhereAll;         // defined in db   Query.ApplyUpdates;   ATransaction.Commit;   Query.Free;   ATransaction.Free;   AConnection.Free; end. 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 any suggestions? ---------------------------------------------------------------------- Zvoni · 2020-02-11 07:41 How curious. That's the exact sample from the Wiki, and you say it doesn't work? https://wiki.lazarus.freepascal.org/SqlDBHowto ---------------------------------------------------------------------- mangakissa · 2020-02-11 08:05 It works for me. Why 'Query.Upda]"]>Blockedde := upWhereAll;  ' after post. This is a property to use before open the dataset. Also upWhereKey is better, because it uses primary key. UpWhereAll uses all oldvalues to find the right record to update. reformat your code 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 AConnection := TSQLite3Connection.Create(nil);  ATransaction := TSQLTransaction.Create(AConnection);try  AConnection.Transaction := ATransaction;  AConnection.DatabaseName := 'test_dbase';  Query := TSQLQuery.Create(nil);  Query.DataBase := AConnection;  Query.SQL.Text := 'select * from tblNames where ID = 2';  Query.Open;  Query.Edit;  Query.FieldByName('NAME').AsString := 'Name Number 2';  Query.Post;  Query.Upda]"]>Blockedde := upWhereAll;         // defined in db  Query.ApplyUpdates;  ATransaction.Commit;finally  Query.Free;  AConnection.Free;end ---------------------------------------------------------------------- egsuh · 2020-02-14 01:27 Does ApplyUpdates take care of deleted records? ---------------------------------------------------------------------- mangakissa · 2020-02-14 07:23 Yes. The procedure updates the database what the container has registraded.