[Lazarus] Cannot open a non-select statement.
Izac Kruger
izac.kruger at gmail.com
Fri Sep 26 15:52:07 CEST 2014
Hi All,
I am new on lazarus,
I got one form on which I performed 2 onClick even on 2 button:
The first button its for INSERT the data in the SQLite database,
The second button its for CLEAR the information on the form.
After I have clicked on the first button to INSERT the data, the operation
goes successfully; 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.
I tried to re-activate/restart the transaction component but still having
the same error.
Please see below my codes:
------------------------------------------------FIRST
BUTTON----------------------------------------------
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, :getHOSTIP,
:getDBNAME, :getUSERNAME, :getPASSWORD);';
DataModuleConn.SQLQuerySQLite.Params.ParamByName('getHOSTNAME').AsString:=lblEdtHostFQDN.Text;
DataModuleConn.SQLQuerySQLite.Params.ParamByName('getHOSTIP').AsString:=lblEdtHostIP.Text;
DataModuleConn.SQLQuerySQLite.Params.ParamByName('getDBNAME').AsString:=lblEdtDBName.Text;
DataModuleConn.SQLQuerySQLite.Params.ParamByName('getUSERNAME').AsString:=lblEdtDBuserName.Text;
DataModuleConn.SQLQuerySQLite.Params.ParamByName('getPASSWORD').AsString:=lblEdtDBPassword.Text;
DataModuleConn.SQLQuerySQLite.ExecSQL;
DataModuleConn.SQLQuerySQLite.SQL.Text:='INSERT INTO textConnection
(hostname, hostip, dbname, username, password) VALUES ('
+':getHOSTNAME, :getHOSTIP,
:getDBNAME, :getUSERNAME, :getPASSWORD);';
DataModuleConn.SQLQuerySQLite.Params.ParamByName('getHOSTNAME').AsString:=lblEdtHostFQDN1.Text;
DataModuleConn.SQLQuerySQLite.Params.ParamByName('getHOSTIP').AsString:=lblEdtHostIP1.Text;
DataModuleConn.SQLQuerySQLite.Params.ParamByName('getDBNAME').AsString:=lblEdtDBName1.Text;
DataModuleConn.SQLQuerySQLite.Params.ParamByName('getUSERNAME').AsString:=lblEdtDBuserName1.Text;
DataModuleConn.SQLQuerySQLite.Params.ParamByName('getPASSWORD').AsString:=lblEdtDBPassword1.Text;
DataModuleConn.SQLQuerySQLite.ExecSQL;
DataModuleConn.SQLQuerySQLite.SQL.Text:='INSERT INTO
binaryConnection (hostname, hostip, dbname, username, password) VALUES ('
+':getHOSTNAME, :getHOSTIP,
:getDBNAME, :getUSERNAME, :getPASSWORD);';
DataModuleConn.SQLQuerySQLite.Params.ParamByName('getHOSTNAME').AsString:=lblEdtHostFQDN2.Text;
DataModuleConn.SQLQuerySQLite.Params.ParamByName('getHOSTIP').AsString:=lblEdtHostIP2.Text;
DataModuleConn.SQLQuerySQLite.Params.ParamByName('getDBNAME').AsString:=lblEdtDBName2.Text;
DataModuleConn.SQLQuerySQLite.Params.ParamByName('getUSERNAME').AsString:=lblEdtDBuserName2.Text;
DataModuleConn.SQLQuerySQLite.Params.ParamByName('getPASSWORD').AsString:=lblEdtDBPassword2.Text;
DataModuleConn.SQLQuerySQLite.ExecSQL;
ShowMessage(msgSuccessful + lisLineEnding + msgSaved);
DataModuleConn.SQLTransSQLite.Commit;
//DataModuleConn.SQLQuerySQLite.Close;
bitBtnOK.Caption:=liBtnUpdate;
bitBtnOK.Enabled:=False;
//DataModuleConn.SQLTransSQLite.StartTransaction;
end else
begin
DataModuleConn.SQLite3Conn.Connected:=False;
DataModuleConn.SQLTransSQLite.Active:=False;
DataModuleConn.SQLQuerySQLite.Active:=False;
end;
end;
------------------------------------------------SECOND
BUTTON-----------------------------------------
begin
lblEdtHostFQDN.Text:='';
lblEdtHostIP.Text:='';
lblEdtDBName.Text:='';
lblEdtDBuserName.Text:='';
lblEdtDBPassword.Text:='';
lblEdtDBPasswordRepeat.Text:='';
lblEdtHostFQDN1.Text:='';
lblEdtHostIP1.Text:='';
lblEdtDBName1.Text:='';
lblEdtDBuserName1.Text:='';
lblEdtDBPassword1.Text:='';
lblEdtDBPasswordRepeat1.Text:='';
lblEdtHostFQDN2.Text:='';
lblEdtHostIP2.Text:='';
lblEdtDBName2.Text:='';
lblEdtDBuserName2.Text:='';
lblEdtDBPassword2.Text:='';
lblEdtDBPasswordRepeat2.Text:='';
ckBoxShowPassword.Checked:=False;
ckBoxShowPassword1.Checked:=False;
ckBoxShowPassword2.Checked:=False;
ckBoxSameAsLogin.Checked:=False;
ckBoxSameAsLogin1.Checked:=False;
ckBoxSameAsTData.Checked:=False;
lblEdtHostFQDN.SetFocus;
bitBtnOK.Caption:=lisOK;
bitBtnOK.Enabled:=True;
if DataModuleConn.SQLTransSQLite.Active=True then
DataModuleConn.SQLTransSQLite.Active:=False;
end;
THANKS
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20140926/90695689/attachment-0002.html>
More information about the Lazarus
mailing list