Ajuda - Busca - Membros - Calendário
Versão Completa: Me Ajudem A Entender Este Erro
Fórum Script Brasil > Programação & Desenvolvimento > Delphi, Kylix
- Carla -
Quando chega no Nome:=, ele dá q o valor é nulo. Provavelmente a cunsulta tem algum erro, mas qual?

while not (qryNiver.Eof) do
Begin
qryNiver.Active := False;
qryNiver.SQL.Clear;
qryNiver.SQL.Add('Select Niver, Nome, Cod from Dados where Cod like "%'+Label6.Caption + '%" and Niver like' + QuotedStr(FormatDateTime('dd/mm',now)));
qryNiver.Active := True;
Nome:= qryNiver.FieldByName('Nome').Value;
Label3.Caption:= 'Hoje é aniversário do(a) ' + Nome;
if qryNiver.RecordCount < 0 then
Label3.Caption:= 'Ninguém faz aniversário Hoje';
qryNiver.Next;
End;

Progr'amador
Olá Carla,
tenta assim:

QUOTE
qryNiver.Close;
qryNiver.SQL.Clear;
qryNiver.SQL.Add('Select Niver, Nome, Cod from Dados where Cod    like "%'+Label6.Caption + '%" and Niver like' + QuotedStr(FormatDateTime  ('dd/mm',now)));
qryNiver.Open;
if qryNiver.RecordCount > 0 then begin
  Nome:= qryNiver.FieldByName('Nome').Value;
  Label3.Caption:= 'Hoje é aniversário do(a) ' + Nome;
end else
  Label3.Caption:= 'Ninguém faz aniversário Hoje';


Abs. Progr'amador. wink.gif
s3c
QUOTE
if qryNiver.RecordCount < 0 then
Acho que essa condição nunca irá acontecer.
Guest
Deu certo, valeu!!
Mas como eu faço caso haja mais de um aniversariante no mesmo dia?
Progr'amador
QUOTE (Guest @ Apr 26 2005, 01:34 PM)
Deu certo, valeu!!
Mas como eu faço caso haja mais de um aniversariante no mesmo dia?

Nesse caso vc pode usar um Memo ou um ListBox por exemplo:

usando Memo:
QUOTE
qryNiver.Close;
qryNiver.SQL.Clear;
qryNiver.SQL.Add('Select Niver, Nome, Cod from Dados where Cod    like "%'+Label6.Caption + '%" and Niver like' + QuotedStr(FormatDateTime  ('dd/mm',now)));
qryNiver.Open;
Memo1.Clear;
if qryNiver.RecordCount > 0 then begin
  qryNiver.First;
  While not qryNiver.EOF do begin
      Memo1.Lines.Add(qryNiver.FieldByName('Nome').AsString);
      qryNiver.Next;
  end;
end else
  Memo1.Text := 'Ninguém faz aniversário Hoje';

usando ListBox:
QUOTE
qryNiver.Close;
qryNiver.SQL.Clear;
qryNiver.SQL.Add('Select Niver, Nome, Cod from Dados where Cod    like "%'+Label6.Caption + '%" and Niver like' + QuotedStr(FormatDateTime  ('dd/mm',now)));
qryNiver.Open;
ListBox1.Clear;
if qryNiver.RecordCount > 0 then begin
  qryNiver.First;
  While not qryNiver.EOF do begin
      ListBox1.Items.Add(qryNiver.FieldByName('Nome').AsString);
      qryNiver.Next;
  end;
end else
  ListBox1.Items.Add('Ninguém faz aniversário Hoje');


Abs. Progr'amador.
Esta é uma versão simplificada de nosso conteúdo principal. Para ver a versão completa com maiores informações, formatação e imagens, por favor clique aqui.
Invision Power Board © 2001-2012 Invision Power Services, Inc.