Sqlite - Write changes to file lazarus / 16-Databases ---------------------------------------------------------------------- P.curtis · 2020-05-13 10:20 When I execute the following 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 var  sSQL : string;  MyQUERY : TSQLQuery;begin  MyQUERY := TSQLQuery.Create(nil);  MyQUERY.Transaction := SQLTransaction1;  sSQL := 'INSERT INTO tnDATA (fnVBITRATE) VALUES (1234)';  MyQUERY.SQL.Add(sSQL);  MyQUERY.ExecSQL;  MyQUERY.Free; The inmemory database is updated. My question is "How to write the changes to disk?" Thanks in advance. Simple project attached ---------------------------------------------------------------------- nouzi · 2020-05-13 11:17 add this befor 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.post ---------------------------------------------------------------------- P.curtis · 2020-05-13 11:49 Nope it don't work. It throws an error "Dataset not in edit or insert state" ---------------------------------------------------------------------- korba812 · 2020-05-13 11:59 You should commit transaction. 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 var  sSQL : string;  MyQUERY : TSQLQuery;begin  MyQUERY := TSQLQuery.Create(nil);  MyQUERY.Transaction := SQLTransaction1;  sSQL := 'INSERT INTO tnDATA (fnVBITRATE) VALUES (1234)';  MyQUERY.SQL.Add(sSQL);  MyQUERY.ExecSQL;  MyQUERY.Free;   SQLTransaction1.Commit;  // <- add this ---------------------------------------------------------------------- af0815 · 2020-05-13 12:01 You can use ApplyUpdates on the query or use the (sqoAutoCommit +) sqoAutoApplyUpdates under Options of the query. See https://wiki.freepascal.org/SqlDBHowto in the middle of the article ---------------------------------------------------------------------- P.curtis · 2020-05-13 12:14 OK, both options are good. Thanks. ---------------------------------------------------------------------- Zoran · 2020-05-13 12:22 Quote from: nouzi on May 13, 2020, 01:17:49 pmadd this befor 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.post  Quote from: af0815 on May 13, 2020, 02:01:02 pmYou can use ApplyUpdates on the query or use the (sqoAutoCommit +) sqoAutoApplyUpdates under Options of the query. See https://wiki.freepascal.org/SqlDBHowto in the middle of the article These posts are misleading, for this particular example you should not use neither Post nor ApplyUpdates, these are for updating previously opened (active) datasets, which this is not. Korba812 gave the correct answer. ---------------------------------------------------------------------- P.curtis · 2020-05-13 12:32 Noted. Thanks.