[Lazarus] Cannot open a non-select statement.

Rik van Kekem rik at graficalc.nl
Fri Sep 26 19:09:36 CEST 2014

Izac Kruger wrote:
> if I clicked on the second button who is to
> removed all the data on the fields, then after  refield again the
> information and clicked on the INSERT button, I received a funny
> message: SQLQeuryLite: Cannot open a non-select statement.

> else begin
>         //DB connections.
>      if DataModuleConn.SQLTransSQLite.Active=False then
>        begin
>         DataModuleConn.SQLite3Conn.Connected:=True;
>         DataModuleConn.SQLTransSQLite.Active:=True;
>         DataModuleConn.SQLQuerySQLite.Active:=True;
>         DataModuleConn.SQLQuerySQLite.SQL.Text:='INSERT INTO
> loginConnection (hostname, hostip, dbname, username, password) VALUES ('
>                                                 +':getHOSTNAME,
You have a line DataModuleConn.SQLQuerySQLite.Active:=True;
This is usually for opening a dataset with a SELECT-statement.
If your SQL is still the INSERT-statement from the previous insert an 
Active:=True will give you that error.

Actually you should make sure the SQLQuerySQLite is NOT active before 
changing the SQL.Text. So if you change that line as follows it should work:
  // ^-- always make sure Active is false before setting SQL.Text

More information about the Lazarus mailing list