Fórum reber uma query como parametro #477570
29/04/2014
0
exemplo:
function retornaQry(stringSql:string):TDataSet;
var
qry : tquery;
begin
qry := tquery.create(nil);
try
qry.DatabaseName := ''dbdados'';
qry.Close;
qry.SQL.Clear;
qry.SQL.add(stringSql);
try
qry.open;
result := qry;
except
end;
finally
freeAndNil(qry);
end;
end;
chamada:
qrysql2 := retornaQry(concat(''select caixas.codcaixa from caixas where caixas.caixaaberto = ''''S'''' and caixas.codterminal = '',sComboBox1.text));Fabio Cardoso
Curtir tópico
+ 0Posts
05/05/2014
Emerson Nascimento
Gostei + 0
08/05/2014
Felippe Tadeu
No result coloque query.Data;
1ªAlteração:
function retornaQry(stringSql:string):OleVariant;
var
qry : tquery;
begin
qry := tquery.create(nil);
try
qry.DatabaseName := ''dbdados''; // O que seria esse dbdados ? Se for uma string tire uma aspas simples de cada lado. Caso não for, coloque a variável sem as aspas.
qry.Close;
qry.SQL.Clear;
qry.SQL.add(stringSql);
try
qry.open;
result := qry.Data;
except
end;
finally
freeAndNil(qry);
end;
end;
2ª Alteração:
qrysql2.Data := retornaQry('select caixas.codcaixa from caixas where caixas.caixaaberto = '+QuotedStr('S')+' and caixas.codterminal = '+sComboBox1.Text);
Gostei + 0
15/09/2015
Fabio Cardoso
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)