The code in question:
procedure TForm1.Button1Click(Sender: TObject);
begin
Form1.ZQuery1.SQL.Add('INSERT INTO logins (Username,Computername) VALUES (:Username,:Computername)');
Form1.ZQuery1.ParamByName('Username').AsString := GetEnvironmentVariable('USERNAME');
Form1.ZQuery1.ParamByName('Computername').AsString := GetEnvironmentVariable('COMPUTERNAME');
begin
if not (CheckBox1.Checked) then
ShowMessage('Read first and check the checkbox!')
else
Form1.ZQuery1.ExecSQL;
Form1.Close;
end
end;
I want to log if users read and confirm the data security instructions. The form works as expected when I comment all ZQuery lines. If the checkbox isn't checked, the message appears, when I click OK there, the program is still alive and waits for a click on the checkbox.
If the ZQuery lines are active and the checkbox is unchecked, the "Read first..." message appears and when I confirm it with OK, the program closes and the SQL isn't executed.
What did I do wrong?
TIA, Michael