Recent

Author Topic: SQlite3 database won't save records  (Read 5542 times)

mrmikehicks

  • New Member
  • *
  • Posts: 39
SQlite3 database won't save records
« on: November 11, 2009, 06:11:02 am »
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

  • Sr. Member
  • ****
  • Posts: 319
    • Davids Freeware
Re: SQlite3 database won't save records
« Reply #1 on: November 11, 2009, 06:48:13 am »
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,
and Primary Key In Dataset in SQLITE3 table DrID
All things considered insanity seems the best option

LacaK

  • Hero Member
  • *****
  • Posts: 680
Re: SQlite3 database won't save records
« Reply #2 on: November 16, 2009, 08:08:11 am »
I'm using sqlit3 in an application.
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

  • New member
  • *
  • Posts: 9
Re: SQlite3 database won't save records
« Reply #3 on: October 27, 2022, 08:54:01 pm »
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.

 

TinyPortal © 2005-2018