Lazarus

Programming => Databases => Topic started by: folkeu08 on November 24, 2020, 07:04:03 pm

Title: [Solved] SQLite3 - Delete a row with a SQLQuery in a DBGrid
Post by: folkeu08 on November 24, 2020, 07:04:03 pm
Hi,
I create an example to insert, edit and delete data in a table under SQLite3.
The insertion works.
I am trying to delete a row of data from the table from part of the row from the DBGrid with an SQLQuery.
I have a problem with the procedure.
Despite the error, if I force the source to continue, the selected row is deleted.
The error tells me that the dataset is only read-only.
I have checked all the readonly properties of the components and the grid, they are indeed false.
I don't see where the problem could be other than in the component properties.
Thank you for your help and I have attached my source to you
Fanch
Title: Re: SQLite3 - Delete a row with a SQLQuery in a DBGrid
Post by: Slyde on November 25, 2020, 07:58:54 pm
myExamplePackage is missing from your files, so I can't run your program.  That said, all of your code and components looks to be in order.  I saw nothing set to Read Only.

Your Query gets executed and deletes the record from your database:
Code: Pascal  [Select][+][-]
  1. Cellule_SQLQuery.SQL.Text := 'delete from Cellule where id_cellule = '+ quotedStr(IntToStr(str))+';' ;
  2. Cellule_SQLQuery.ExecSQL;

and then you make this call:
Code: Pascal  [Select][+][-]
  1. Cellule_SQLQuery.Delete;

That might be your problem.
TinyPortal © 2005-2018