[Lazarus] Cannot open a non-select statement.

Izac Kruger izac.kruger at gmail.com
Mon Sep 29 17:51:53 CEST 2014


Thanks a lot, its works
On 26 Sep 2014 19:09, "Rik van Kekem" <rik at graficalc.nl> wrote:

> 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;
> Why?
> 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:
>  DataModuleConn.SQLQuerySQLite.Active:=False;
>  // ^-- always make sure Active is false before setting SQL.Text
>
>
> --
> _______________________________________________
> Lazarus mailing list
> Lazarus at lists.lazarus.freepascal.org
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20140929/e54c52dc/attachment-0003.html>


More information about the Lazarus mailing list