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
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.UpdateMode := upWhereAll; // defined in db
Query.ApplyUpdates;
ATransaction.Commit;
Query.Free;
ATransaction.Free;
AConnection.Free;
end.
any suggestions?