Fórum consulta usando um edit #208056
21/01/2004
0
Gostaria de saber como que eu faço uma consulta usando um edit, um query e um data source, qd o usuario digitar o que ele quizer consultar em um edit e a resposta vim em um DbGrid
Gdg2001
Curtir tópico
+ 0
Responder
Posts
21/01/2004
Rômulo Barros
Query.Close;
Query.sql.clear;
Query.sql.add(´SELECT * FROM TABELA WHERE CAMPO=:PCAMPO´);
Query.ParamByName(´PCAMPO´).AsString := Edit.Text;
Query.Open;
Responder
Gostei + 0
21/01/2004
Ajpbotelho
No evento OnChange do Edit coloca o seguinte:
With Query, Edit1 do
begin
If Text <> ´´ then
If not IsCharAlpha(Text[1]) then
Locate(´Codigo´, Text, [loPartialKey]) // codigo - campo
Else
Locate(´Nome´, Text, [loPartialKey, loCaseInsensitive]); // nome - campo
end;
With Query, Edit1 do
begin
If Text <> ´´ then
If not IsCharAlpha(Text[1]) then
Locate(´Codigo´, Text, [loPartialKey]) // codigo - campo
Else
Locate(´Nome´, Text, [loPartialKey, loCaseInsensitive]); // nome - campo
end;
Responder
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)