[Solved] SQLite SQLQuery: cannot open a non-select statement lazarus / 16-Databases ---------------------------------------------------------------------- jeanchristophe · 2014-08-12 07:49 Hello Many times answered thread, but I can't find out, what is wrong with these lines: Code: [Select]procedure TForm1.Button1Click(Sender: TObject); begin   if SQLite3Connection1.Connected = true then SQLite3Connection1.Connected:= false;   if SQLTransaction1.Active = true then SQLTransaction1.Active:= false;   if SQLQuery1.Active = true then SQLQuery1.Active:= false;   SQLite3Connection1.DatabaseName:= Edit1.Text;   if SQLite3Connection1.Connected = false then SQLite3Connection1.Connected:= true;   SQLTransaction1.DataBase:= SQLite3Connection1;   if SQLTransaction1.Active = false then SQLTransaction1.Active:= true;   SQLQuery1.DataBase:= SQLite3Connection1;   SQLQuery1.Transaction:= SQLTransaction1;   SQLQuery1.SQL.Add(Edit2.Text);   if SQLQuery1.Active = false then SQLQuery1.Active:= true;   DataSource1.DataSet:= SQLQuery1; end; procedure TForm1.Button2Click(Sender: TObject); begin   if SQLQuery1.Active = true then SQLQuery1.Active:= false;   SQLQuery1.SQL.Clear;   SQLQuery1.SQL.Add('insert into test (ID, Dats) values (4, "test4");');   if SQLQuery1.Active = false then SQLQuery1.Active:= true;   SQLQuery1.ExecSQL;   SQLTransAction1.Commit;   SQLQuery1.Close; end;                          If I run the command manually into SQLite throught Firefox, it is working. I can see the data in the DBGrid..... I just can't find out, sorry Best Regards Jean-Christophe ---------------------------------------------------------------------- BigChimp · 2014-08-12 08:14 Seems like you have data bound controls linked to your sqlquery1. How are they supposed to get their data out of an SQL statement that does not return values (your insert statement?) Solution: use a different sqlquery or (possibly, don't know) erase the sql text after running the query and replace with a select statement. ---------------------------------------------------------------------- jeanchristophe · 2014-08-12 10:01 Thank you for your answer BigChimp I found out, by not using: if SQLQuery1.Active = false then SQLQuery1.Active:= true; It is now working! Code: [Select]if SQLQuery1.Active = true then SQLQuery1.Active:= false; SQLQuery1.SQL.Clear; SQLQuery1.SQL.Add('insert into test (ID, Dats) values (4, "test4");'); //if SQLQuery1.Active = false then SQLQuery1.Active:= true; SQLQuery1.ExecSQL; SQLTransAction1.Commit; SQLQuery1.Close; Have a nice day! Best Regards Jean-Christophe