Registro não encontrado!
10/08/2004
0
ADOQuery1.Close; ADOQuery1.SQL.Clear; ADOQuery1.SQL.Add(´SELECT Nome, Telefone FROM tb_profe´); ADOQuery1.SQL.Add(´WHERE Nome=´+´´´´+Edit1.Text+´´´´); /// olha aqui a alteração ADOQuery1.Open;
tinha feito algo como:
if ADOQuery1.EOF then
blabla
mas não sei se está coerente isso, alguem pode me dar uma luz?
obrigado.
Rockbilly
Posts
10/08/2004
Melo
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add(´SELECT Nome, Telefone FROM tb_profe´);
ADOQuery1.SQL.Add(´WHERE Nome=´+´´´´+Edit1.Text+´´´´); /// olha aqui a alteração
ADOQuery1.Open;
// a Verificação se a Query esta vazia ou não
if ADOQuery1.isEmpty then
Showmessage(´A pesquisa não retornou nenhum Resultado´)
Espero Ter Ajudado
Melo
13/08/2004
Rockbilly
if not (ADOQuery1.IsEmpty) Then begin ADOQuery1.SQL.Add(´SELECT Nome As NOMES, Telefone As FONE FROM tb_profe´); ADOQuery1.SQL.Add(´WHERE Nome=´+´´´´+Edit1.Text+´´´´); ADOQuery1.Open; ADOQuery1.Close; ADOQuery1.SQL.Clear; end else begin ShowMessage(´Registro não encontrado!´); end; end;
e tb:
if not (ADOQuery1.EOF) Then begin ADOQuery1.SQL.Add(´SELECT Nome As NOMES, Telefone As FONE FROM tb_profe´); ADOQuery1.SQL.Add(´WHERE Nome=´+´´´´+Edit1.Text+´´´´); ADOQuery1.Open; ADOQuery1.Close; ADOQuery1.SQL.Clear; end else begin ShowMessage(´Registro não encontrado!´); end; end;
13/08/2004
Rockbilly
if not (ADOQuery1.IsEmpty) Then begin ADOQuery1.Close; ADOQuery1.SQL.Clear; ADOQuery1.SQL.Add(´SELECT Nome As NOMES, Telefone As FONE FROM tb_profe´); ADOQuery1.SQL.Add(´WHERE Nome=´+´´´´+Edit1.Text+´´´´); ADOQuery1.Open; end else begin ShowMessage(´Registro não encontrado!´); end; end;
e tb:
if not (ADOQuery1.EOF) Then begin ADOQuery1.Close; ADOQuery1.SQL.Clear; ADOQuery1.SQL.Add(´SELECT Nome As NOMES, Telefone As FONE FROM tb_profe´); ADOQuery1.SQL.Add(´WHERE Nome=´+´´´´+Edit1.Text+´´´´); ADOQuery1.Open; end else begin ShowMessage(´Registro não encontrado!´); end; end;
13/08/2004
Macario
if not (ADOQuery1.IsEmpty) Then begin ADOQuery1.Close; ADOQuery1.SQL.Clear; ADOQuery1.SQL.Add(´SELECT Nome As NOMES, Telefone As FONE FROM tb_profe´); ADOQuery1.SQL.Add(´WHERE Nome=´+´´´´+Edit1.Text+´´´´); ADOQuery1.Open; end else begin ShowMessage(´Registro não encontrado!´); end; end;
if not (ADOQuery1.EOF) Then begin ADOQuery1.Close; ADOQuery1.SQL.Clear; ADOQuery1.SQL.Add(´SELECT Nome As NOMES, Telefone As FONE FROM tb_profe´); ADOQuery1.SQL.Add(´WHERE Nome=´+´´´´+Edit1.Text+´´´´); ADOQuery1.Open; end else begin ShowMessage(´Registro não encontrado!´); end; end;
Olá programador, boa tarde.
Primeiro voce executa a Query, e depois verifica o estado da mesma.
13/08/2004
Rockbilly
13/08/2004
Macario
Tente assim:
with ADOQuery1 do begin Close; SQL.Clear; SQL.Add(´SELECT Nome As NOMES, Telefone As FONE FROM tb_profe´); SQL.Add(´WHERE Nome=´+QuotedStr(Edit1.Text); Open; end; if ADOQuery1.isEmpty then ShowMessage(´Não há dados a exibir´);
ou assim:
with ADOQuery1 do begin Close; SQL.Clear; SQL.Add(´SELECT Nome As NOMES, Telefone As FONE FROM tb_profe´); SQL.Add(´WHERE Nome= :Codigo´); [color=red] Params.ParamByName(´Codigo´).asString := edit1.text;[/color] Open; end; if ADOQuery1.isEmpty then ShowMessage(´Não há dados a exibir´);
na linha em vermelho voce usa atribui o parametro conforme o tipo do dado: string, integer, float,etc
Qualquer coisa estamos por aqui.
13/08/2004
Paullus
// seu código da pesquisa ADOQuery1.Active := true; if ADOQuery1.RecordCount = 0 then ShowMessage(´Nome não encontrado´);
A propriedade [b:df1fd7eddb]RecordCount[/b:df1fd7eddb] de qualquer TDataSet te retorna a quantidade de registros informadas.
13/08/2004
Vinicius2k
Qualquer TDataSet não... exemplos :
IBX - IBQuery e IBDataSet, sem aplicação do FetchAll não retorna corretamente...
dbExpress - SQLQuery e SQLDataSet, se existirem parametros ou forem Selects com Joins, a leitura causa exceção...
T+
17/08/2004
Paullus
Dessa eu não sabia. :oops:
Vivendo e aprendendo... obrigado. :wink:
20/08/2020
Socrates Foschera
estou com uma duvida depois que verifico se o registro esta vazio
procedure TFrmRelacao_Veiculo.FormActivate(Sender: TObject);
begin
with dm.PesquisaRelacao_Veiculos do
begin
Close;
SQL.Clear;
SQL.Add('select * from relacao_veiculo');
sql.Add('where (nome)');
EDTPesquisa_Relacao_Veiculo.Text := FrmCadastro_Consulta_Cliente.Edit2.Text;
SQL.Add('like ('''+EDTPesquisa_Relacao_Veiculo.Text+''')');
open;
end;
if dm.PesquisaRelacao_Veiculos.IsEmpty then
begin
ShowMessage('Registro não encontrado');
end;
end;
a duvida é a seguinte como faço depois que ele deu a menssagem para ele fechar o form?
Clique aqui para fazer login e interagir na Comunidade :)