Cannot open a non-select statement lazarus / 16-Databases ---------------------------------------------------------------------- dietmar · 2021-08-16 17:22 Hi, I am struggling with creating a small sqlite test database. The three components (connection, transaction, query) are connected to each other correctly. Error message is: "Cannot open a non-select statement" Code: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i     SQLite3TestConnection.DatabaseName := 'xxx.db';    try      SQLite3TestConnection.Connected := True;      SQLTestTransaction.Active := True;    except      on E: Exception do begin        ShowMessage( 'Error: '+ E.ClassName + #13#10 + E.Message );        Application.Terminate;      end;    end;    try      SQLTestQuery.Close;      SQLTestQuery.SQL.Clear;      SQLTestQuery.SQL.Add('create table test (nr int(10), name varchar(64));');      SQLTestQuery.SQL.Add('insert into test (nr, name) values ("1", "Amaryllis")');      SQLTestQuery.Open; // <--- error occurs here      SQLTestQuery.ExecSQL;      SQLTestTransAction.Commit;      SQLTestQuery.Close;      SQLTestTransaction.Active := False;      SQLite3TestConnection.Connected := False;    except      on E: Exception do begin        ShowMessage( 'Error: '+ E.ClassName + #13#10 + E.Message );        Application.Terminate;      end;    end;  Thanks for your help. --Dietmar ---------------------------------------------------------------------- JanRoza · 2021-08-16 17:24 For select sql statements use Open, for other sql statements like Insert, Delete, etc. use ExecSQL. So just remove the query Open statement. ---------------------------------------------------------------------- dietmar · 2021-08-16 17:53 Thx, but now, only the "create table" statement is executed, the following "insert into" is ignored. so the table stays empty... --Dietmar ---------------------------------------------------------------------- JanRoza · 2021-08-16 19:37 You are trying to do two sql statement with one execsql statement, that is not possible. First do a execsql with the create statement after that do a second execsql with the insert sql statement. ---------------------------------------------------------------------- dietmar · 2021-08-16 20:42 Thanks for helping beginners --Dietmar ---------------------------------------------------------------------- JanRoza · 2021-08-17 14:08 You’re welcome! We all were beginners once.