consulta usando um edit
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
Curtidas 0
Respostas
Rômulo Barros
21/01/2004
Query.Close;
Query.sql.clear;
Query.sql.add(´SELECT * FROM TABELA WHERE CAMPO=:PCAMPO´);
Query.ParamByName(´PCAMPO´).AsString := Edit.Text;
Query.Open;
GOSTEI 0
Ajpbotelho
21/01/2004
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;
GOSTEI 0