Fórum Como fazer consulta? #187399
09/10/2003
0
Estou precisando da ajuda de vocês. Estou usando o interbase 6 e preciso fazer uma consulta para entrar com um nome em uma caixa de texto e ele pesquisar este nome.
Ex:
TEnho o nome Carlos chagas Pereira. Eu digito na caixa Chagas e ele consulta todos os nomes que tenha como sobrenome chagas. Digito Pereira e consulta também.
No interbase a seguinte instrução funciona:
Select * from funcionarios where nome like ´¬SILVESTRE¬´
Mais não sei como colocar isto em um formulário será que alguém pode ajudar?
Obrigado.
Francisco.gorgulho
Curtir tópico
+ 0Posts
09/10/2003
Bampavao
procedure TfrmPesquisa.BitBtn2Click(Sender: TObject);
var sNome: String;
begin
sNome := InputBox(´Pesquisa´,
´Entre com o nome do Cidadão ´, ´´ );
if sNome = ´´ then Exit;
with ´SuaQuery´ do begin
SQL.Clear;
Close;
SQL.Add(´Select * from funcionarios where nome like :Nome´);
Parameters.ParamByName(´Nome´).Value := ´¬´+sNome+´¬´;
Open;
ExecSQL;
end;
end;
Gostei + 0
09/10/2003
Francisco.gorgulho
IBQUERY1.CANNOT PERFORM THIS OPERATION ON NA OPEN DATASET.
Assim que aparece esse erro é só clicar em ok. Que passa. Eu gostaria de tirar esse erro
Alguém pode me ajudar?
procedure TForm4.Button1Click(Sender: TObject);
var sNome: String;
begin
sNome := InputBox(´Pesquisa´,´Entre com o nome do Cidadão ´, ´´ );
if sNome = ´´ then Exit;
with IBQuery1 do begin
SQL.Clear;
Close;
SQL.Add(´Select * from funcionarios where nome like :Nome´);
Params.ParamByName(´Nome´).Value := ´¬´+sNome+´¬´;
Open;
ExecSQL;
end;
end;
Gostei + 0
09/10/2003
Anorex
Gostei + 0
09/10/2003
Imoreira
http://delphiforum.icft.com.br/forum/viewtopic.php?t=23977
Gostei + 0
09/10/2003
Dart
Valeu
Dart
Gostei + 0
09/10/2003
Bampavao
Falow
Gostei + 0
09/10/2003
Imoreira
Gostei + 0
10/10/2003
Dart
eu fiz assim so que nao funfou.
Por Que?
var sNome: String;
begin
sNome := InputBox(´Pesquisa´,´Entre com o nome do Cidadão ´, ´´ );
if sNome = ´´ then Exit;
with Query1 do begin
SQL.Clear;
Close;
SQL.Add(´Select * from clientes where nome like :Nome´);
Params.ParamByName(´Nome´).Value := ´¬´+sNome+´¬´;
Open;
end;
end;
o dbgrid fica em branco.
Valeu
Gostei + 0
10/10/2003
Outl@w
SQL.Add(´Select * from clientes where nome like :Nome´);
Params.ParamByName(´Nome´).Value := ´¬´+sNome+´¬´;
Tente:
SQL.Add(´Select * from clientes where nome like Nome = ´+´¬´+sNome+´¬´);
Eu não testei mas acho que funciona...
Gostei + 0
10/10/2003
Dart
SQL.Add(´Select * from clientes where nome like razao = ´+´¬´+sNome+´¬´);
invalid used of keyword.
token: =
line number: 1
Gostei + 0
10/10/2003
Marcelo.c
SQL.Add(´Select * from clientes where nome like ´+QuotedStr(´¬´+sNome+´¬´));
ou
SQL.Add(´Select * from clientes where razao like ´+QuotedStr(´¬´+sNome+´¬´));
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)