Here's a simple hint to help resolve the issue:
In a new form add a Memo, a Grid and 3 buttons (See, Change and Clean).
A database connection component (ADOConnection1, for example), a query (ADOQuery, for example), and a DataSource.
Make the necessary changes to access your database.
Names of components used in the project:
Memo = memscript,
ADOQuery = qry RunSQL,
Botoes = btnConsult, btnChange and btnClear.
The following is the code for each component:
procedure TfrmConsultaBancoDados.btnConsultarClick(Sender: TObject);
begin
Try
with qryExecutarSQL do
begin
close;
SQL := memScript.Lines;
Open;
end;
Except
ShowMessage('Erro ao tentar consultar Banco de Dados');
end;
end;
procedure TfrmConsultaBancoDados.btnAlterarClick(Sender: TObject);
begin
Try
with qryExecutarSQL do
begin
close;
SQL := memScript.Lines;
ExecSQL;
end;
Except
ShowMessage('Erro ao tentar Alterar Banco de Dados');
end;
end;
procedure TfrmConsultaBancoDados.btnLimparClick(Sender: TObject);
begin
memScript.Clear;
end;
procedure TfrmConsultaBancoDados.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
qryExecutarSQL.Close;
end;