procedure TForm1.ExecSQLClick(Sender: TObject);
begin
 if not (TestSQL.State = dsInactive) then
  TestSQL.Close;
 TestSQL.SQL.Clear;
 TestSQL.SQL.AddStrings(InputSQL.Lines);
 TestSQL.Open;
end;

procedure TForm1.FormDeactivate(Sender: TObject);
begin
 TestSQL.Close;
end;