Conteudo do CommandText
Boa tarde a todos.
Tenho o seguinte comando:
if (DBGrid.DataSource.DataSet is TClientDataSet) then
begin
if not (DBGrid.DataSource.DataSet as TClientDataSet).Active then
begin
(DBGrid.DataSource.DataSet as TClientDataSet).Open;
strSqlAtual:= (DBGrid.DataSource.DataSet as TClientDataSet).CommandText;
end;
end; Na linha em negrito eu queria pegar o conteudo do CommandText do DataSet linkado ao dbgrid.. Ele está passando o valor vazio ''. Alguem sabe como fazer isso? Aguardo...
begin
if not (DBGrid.DataSource.DataSet as TClientDataSet).Active then
begin
(DBGrid.DataSource.DataSet as TClientDataSet).Open;
strSqlAtual:= (DBGrid.DataSource.DataSet as TClientDataSet).CommandText;
end;
end; Na linha em negrito eu queria pegar o conteudo do CommandText do DataSet linkado ao dbgrid.. Ele está passando o valor vazio ''. Alguem sabe como fazer isso? Aguardo...
Carlos Júnior
Curtidas 0
Respostas
Paulo Silva
06/11/2009
Ola amigo tente isso
procedure TForm1.BitBtn1Click(Sender: TObject);
var
sql:string;
begin
try
if (DBGrid.DataSource.DataSet is TClientDataSet) then
begin
if not (DBGrid.DataSource.DataSet as TClientDataSet).Active then
begin
(DBGrid.DataSource.DataSet as TClientDataSet).Open;
Sql:= TClientDataSet(dbgrid.DataSource.DataSet).CommandText;
showmessage(sql);
end;
end;
except
raise Exception.Create('Nao foi possivel recuperar o comando');
end; end;
var
sql:string;
begin
try
if (DBGrid.DataSource.DataSet is TClientDataSet) then
begin
if not (DBGrid.DataSource.DataSet as TClientDataSet).Active then
begin
(DBGrid.DataSource.DataSet as TClientDataSet).Open;
Sql:= TClientDataSet(dbgrid.DataSource.DataSet).CommandText;
showmessage(sql);
end;
end;
except
raise Exception.Create('Nao foi possivel recuperar o comando');
end; end;
GOSTEI 0
Carlos Júnior
06/11/2009
Amigo,
Seu código tb não resolveu..
Fiz de outra forma..
criei uma variavel constante, e passei a sql pra ela...
Obrigado.
GOSTEI 0