I am using Delphi 2010 with Tim Anderson’s SQLite wrapper (unicode version)
Have a SQLite3 database that is currently around a thousand records.
I am trying implement a feature were the user can walk through the database using Next/Previous buttons, edit a record if they desire then move on to the next record.
When I update one of the records the currently loaded table is acting like a snapshot i.e. the table shows the old data until I rerun the SQL query to reload the table.
Here is the Delphi code that does the update.
procedure TForm1.btnUpdateClick(Sender: TObject);
var
slDBpath: string;
sldb: TSQLiteDatabase;
sSQL: String;
ts: TStringStream;
begin
slDBpath := ExtractFilepath(application.exename) + 'test.db';
sldb := TSQLiteDatabase.Create(slDBpath);
try
ts := TStringStream.Create(memNotes.Text, TEncoding.UTF8);
try
sldb.BeginTransaction;
sSQL := 'UPDATE testtable SET Name = "' + ebName.Text + '", Number = ' + ebNumber.Text + ' WHERE ID = '+ ebID.text +';';
sldb.execsql(sSQL);
sldb.Commit;
finally
ts.Free;
end;
finally
sldb.Free;
end;
end;
Is there a way to refresh the currently loaded table?
Or do I have to rerun the original query and walk my way back to the currently used record?
I worked around it by using TSQLiteTable to create an array of ID#’s and use TSQLiteUniTable to show or edit the data based on the record’s ID#. Very simple and more than fast enough for number of records this application will deal with.