O que está errado nesta consulta?
If Nome.Checked = true then begin if RbExata.Checked = true then begin DM.LocFunc.Close; DM.LocFunc.SQL.Clear; DM.LocFunc.SQL.Add(´Select * from funcionarios where nome= :geral´); DM.LocFunc.Parameters.ParamByName(´geral´).Value:=EdSentenca.Text; DM.LocFunc.Prepared; DM.LocFunc.Open; //TabResult.SetFocus; if DM.LocFunc.RecordCount = 0 then begin ShowMessage(´Não foi encontrado nenhum valor com esta sentença: ´+EdSentenca.Text); //TabLoc.SetFocus; EdSentenca.Text:=´´; EdSentenca.SetFocus; end; end else begin DM.LocFunc.Close; DM.LocFunc.SQL.Clear; DM.LocFunc.SQL.Add(´Select * from funcionarios where nome = :geral´); DM.LocFunc.Parameters.ParamByName(´geral´).Value:=´¬´+EdSentenca.Text+´¬´; DM.LocFunc.Prepared; DM.LocFunc.Open; //TabResult.SetFocus; if DM.LocFunc.RecordCount = 0 then begin ShowMessage(´Não foi encontrado nenhum valor com esta sentença: ´+EdSentenca.Text); //TabLoc.SetFocus; EdSentenca.Text:=´´; EdSentenca.SetFocus; end;
E sempre me retorna o seguinte erro:
[i:d81bf9cf92][b:d81bf9cf92]Nenhum valor foi fornecido para um ou mais parâmetros requeridos[/b:d81bf9cf92][/i:d81bf9cf92]
Será que alguém sabe o que está errado?
Valeu!
Angelo
Angelo
Curtidas 0
Respostas
Nigro
05/09/2003
Ao invés de .value, tente colocar .asStrring;
GOSTEI 0
Angelo
05/09/2003
o ADOQery não aceita este parâmetro.
:(
:(
GOSTEI 0
Nigro
05/09/2003
Analisando melhor suas linhas, fiz algumas mudanças, e creio que agora funcione...
if Nome.Checked = true then
begin
if RbExata.Checked = true then
begin
with DM.LocFunc do
begin
Close;
Unprepare;
SQL.Clear;
Add(´Select * from funcionarios where nome = :geral´);
Params[0].AsString :=EdSentenca.Text;
Prepare;
Open;
if RecordCount = 0 then
begin
ShowMessage(´Não foi encontrado nenhum valor com esta sentença: ´+EdSentenca.Text);
EdSentenca.Text:=´´;
EdSentenca.SetFocus;
end;
end;
end
else
begin
Close;
Unprepare;
DM.LocFunc.SQL.Clear;
DM.LocFunc.SQL.Add(´Select * from funcionarios where nome like :geral´);
DM.LocFunc.Parames[0].AsStrring := ´¬´ + EdSentenca.Text+ ´¬´;
DM.LocFunc.Prepare;
DM.LocFunc.Open;
if DM.LocFunc.RecordCount = 0 then
begin
ShowMessage(´Não foi encontrado nenhum valor com esta sentença: ´+ EdSentenca.Text);
EdSentenca.Text:=´´;
EdSentenca.SetFocus;
end;
end;
if Nome.Checked = true then
begin
if RbExata.Checked = true then
begin
with DM.LocFunc do
begin
Close;
Unprepare;
SQL.Clear;
Add(´Select * from funcionarios where nome = :geral´);
Params[0].AsString :=EdSentenca.Text;
Prepare;
Open;
if RecordCount = 0 then
begin
ShowMessage(´Não foi encontrado nenhum valor com esta sentença: ´+EdSentenca.Text);
EdSentenca.Text:=´´;
EdSentenca.SetFocus;
end;
end;
end
else
begin
Close;
Unprepare;
DM.LocFunc.SQL.Clear;
DM.LocFunc.SQL.Add(´Select * from funcionarios where nome like :geral´);
DM.LocFunc.Parames[0].AsStrring := ´¬´ + EdSentenca.Text+ ´¬´;
DM.LocFunc.Prepare;
DM.LocFunc.Open;
if DM.LocFunc.RecordCount = 0 then
begin
ShowMessage(´Não foi encontrado nenhum valor com esta sentença: ´+ EdSentenca.Text);
EdSentenca.Text:=´´;
EdSentenca.SetFocus;
end;
end;
GOSTEI 0
Nigro
05/09/2003
Desculpe, mas não reparei se você disse estar trabalhando com ADOQuery
GOSTEI 0
_nekinho_
05/09/2003
Vi muito rapidamente seu codigo e não analisei tudo mas bati o olho ali cara e vi um tal de RecordCount, confesso que nunca mexei com o tal ADO mas procura nele algo como isEmpty para indicar q a Query ta vazia. Já vi problemas com RecordCount e esse isEmpty não ta aê hehehehe sem mais....
Abraços,
Nelson Lima - Eu aposto do FireBird =)
Abraços,
Nelson Lima - Eu aposto do FireBird =)
GOSTEI 0
Complex
05/09/2003
Coisa simples..
coloca o sql no ADOQuery.. vai em parameters e muda DataType pra ftWideString ai remove o sql..
[/code]
coloca o sql no ADOQuery.. vai em parameters e muda DataType pra ftWideString ai remove o sql..
DM.LocFunc.Parameters[0].Value := EdSentenca.Text;
GOSTEI 0
Fabio.hc
05/09/2003
If Nome.Checked = true then
begin
if RbExata.Checked = true then
begin
DM.LocFunc.Close;
DM.LocFunc.SQL.Clear;
DM.LocFunc.SQL.Add(´Select * from funcionarios where nome= :geral´);
DM.LocFunc.Parameters.ParamByName(´geral´).Value:=EdSentenca.Text;
DM.LocFunc.Prepared;
DM.LocFunc.Open;
//TabResult.SetFocus;
if DM.LocFunc.RecordCount = 0 then
begin
ShowMessage(´Não foi encontrado nenhum valor com esta sentença: ´+EdSentenca.Text);
//TabLoc.SetFocus;
EdSentenca.Text:=´´;
EdSentenca.SetFocus;
end;
end
else
begin
DM.LocFunc.Close;
DM.LocFunc.SQL.Clear;
DM.LocFunc.SQL.Add(´Select * from funcionarios where nome = :geral´);
DM.LocFunc.Parameters.ParamByName(´geral´).Value:=´¬´+EdSentenca.Text+´¬´;
DM.LocFunc.Prepared;
DM.LocFunc.Open;
//TabResult.SetFocus;
if DM.LocFunc.RecordCount = 0 then
begin
ShowMessage(´Não foi encontrado nenhum valor com esta sentença: ´+EdSentenca.Text);
//TabLoc.SetFocus;
EdSentenca.Text:=´´;
EdSentenca.SetFocus;
end;
E sempre me retorna o seguinte erro:
Nenhum valor foi fornecido para um ou mais parâmetros
tente assim:
DM.LocFunc.Parameters.ParamByName(´geral´).Value:=´¬´+ [color=blue:69ffa2001b]TRIM[/color:69ffa2001b](EdSentenca.Text)+´¬´;
begin
if RbExata.Checked = true then
begin
DM.LocFunc.Close;
DM.LocFunc.SQL.Clear;
DM.LocFunc.SQL.Add(´Select * from funcionarios where nome= :geral´);
DM.LocFunc.Parameters.ParamByName(´geral´).Value:=EdSentenca.Text;
DM.LocFunc.Prepared;
DM.LocFunc.Open;
//TabResult.SetFocus;
if DM.LocFunc.RecordCount = 0 then
begin
ShowMessage(´Não foi encontrado nenhum valor com esta sentença: ´+EdSentenca.Text);
//TabLoc.SetFocus;
EdSentenca.Text:=´´;
EdSentenca.SetFocus;
end;
end
else
begin
DM.LocFunc.Close;
DM.LocFunc.SQL.Clear;
DM.LocFunc.SQL.Add(´Select * from funcionarios where nome = :geral´);
DM.LocFunc.Parameters.ParamByName(´geral´).Value:=´¬´+EdSentenca.Text+´¬´;
DM.LocFunc.Prepared;
DM.LocFunc.Open;
//TabResult.SetFocus;
if DM.LocFunc.RecordCount = 0 then
begin
ShowMessage(´Não foi encontrado nenhum valor com esta sentença: ´+EdSentenca.Text);
//TabLoc.SetFocus;
EdSentenca.Text:=´´;
EdSentenca.SetFocus;
end;
E sempre me retorna o seguinte erro:
Nenhum valor foi fornecido para um ou mais parâmetros
tente assim:
DM.LocFunc.Parameters.ParamByName(´geral´).Value:=´¬´+ [color=blue:69ffa2001b]TRIM[/color:69ffa2001b](EdSentenca.Text)+´¬´;
GOSTEI 0
Angelo
05/09/2003
Infelizmente nada funcionou, continua dando a mesma mensagem...
:(
:(
GOSTEI 0
Angelo
05/09/2003
Não posso utilizar o TRIM, pois senão eu tiro os espaços entre o nome do funcionário, aí não vai aparecer nada mesmo, he he
Valeu...
Valeu...
GOSTEI 0
Fabio.hc
05/09/2003
DM.LocFunc.SQL.Add(´Select * from funcionarios where nome = :geral´);
DM.LocFunc.Parameters.ParamByName´geral´).Value:=´¬´+EdSentenca.Text+´¬´;
tente assim:
DM.LocFunc.SQL.Add(´Select * from funcionarios where nome like´ +QuotedStr(´¬´+EdSentenca.Text+´¬´));
DM.LocFunc.Parameters.ParamByName´geral´).Value:=´¬´+EdSentenca.Text+´¬´;
tente assim:
DM.LocFunc.SQL.Add(´Select * from funcionarios where nome like´ +QuotedStr(´¬´+EdSentenca.Text+´¬´));
GOSTEI 0
Fernandoprog
05/09/2003
É simples. Seu erro está no Select, o parametro.
DM.LocFunc.SQL.Add(´Select * from funcionarios where nome = :geral´)
O seu parametro está afastado do sinal de igualdade [b:7faba6f20d]...nome = :geral[/b:7faba6f20d].
Logo deve estar assim [i:7faba6f20d][b:7faba6f20d]...nome =:geral[/b:7faba6f20d][/i:7faba6f20d]. Basta eliminar o espaço entre o sinal de igualdade e o seu parametro.
Atenciosamente,
Fernando - Programador
Florianópolis/SC
DM.LocFunc.SQL.Add(´Select * from funcionarios where nome = :geral´)
O seu parametro está afastado do sinal de igualdade [b:7faba6f20d]...nome = :geral[/b:7faba6f20d].
Logo deve estar assim [i:7faba6f20d][b:7faba6f20d]...nome =:geral[/b:7faba6f20d][/i:7faba6f20d]. Basta eliminar o espaço entre o sinal de igualdade e o seu parametro.
Atenciosamente,
Fernando - Programador
Florianópolis/SC
GOSTEI 0