Forum > Databases

SQlite3 database won't save records

(1/1)

mrmikehicks:
I'm using sqlit3 in an application. When I add a record to the database, it works fine, but when I try to delete a record, it shows that the record is deleted, but if I close the program and go back in again, the deleted record is still there. It's like the delete transaction is not sticking. The event handler for the dbnavigator uses an after delete and an after post:
procedure Tmain_form.sqlite_ds_itemAfterDelete(DataSet: TDataSet);
begin
     dmr.sqlite_ds_item.UpdateRecord;
     dmr.sqlite_ds_item.ApplyUpdates;
end;

procedure Tmain_form.sqlite_ds_itemAfterPost(DataSet: TDataSet);
begin
     dmr.sqlite_ds_item.UpdateRecord;
     dmr.sqlite_ds_item.ApplyUpdates;
end;
I think this should work but don't know why the database is not being saved when the program closes.
     Thanks for any and all advice on this problem.
     Mike

davesimplewear:
I don't know if you already tried this but assigning a primary key in the db and in the sqlite dataset is important otherwise changes aren't always done.

--- Quote ---CREATE TABLE Debtor
(
   DrID       INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE NOT NULL,
--- End quote ---
and Primary Key In Dataset in SQLITE3 table DrID

LacaK:

--- Quote from: mrmikehicks on November 11, 2009, 06:11:02 am ---I'm using sqlit3 in an application.

--- End quote ---
Please specify, which components do you use ?
TSQLite3Connection+TSQLQuery
If yes, then you must also Commit changes ...
If no, there may be problem if some fields are NULL ...

ercolesptr:
I know it has been 13 years since the last post but since no one provided the solution and I spent hours to find it I decided to post it for the sake of other coders.

For the Delete button in DBNavigator to work you must set the following 2 Option settings to True in your SQLQuery component:

sqoAutoApplyUpdates
sqoAutoCommit

Once these are ticked Delete works normally then.

Navigation

[0] Message Index

Go to full version