O que tem de errado neste codigo?
Pessoal, o que ha de errado neste codigo? Quand oexecuto ele no Delphi., ele me retorna apenas 1 registro, porem quando executo o mesmo codigo no IB Expert ele me retorna o total de registro, mais de 10.
nesta query
O CodBoletim, vem certo ou seja 1, 2 no caso...
entao se eu vou no IBExpert e uso
Funciona perfeitamente... ja debuguei e vi que o valor da variavel CodBoletim é passado corretamente
entao o que pode estar acontecendo?
desde ja agradeco
[]s
cQuery2.SQL.Clear; cQuery2.SQL.Add(´select * from BOLETIM_NOTAS_FINAL´); cQuery2.SQL.Add(´where COD_BOLETIM = ´ + IntToStr(CodBoletim)); cQuery2.Prepare; cQuery2.Open; j := 0; if DM.MemBoletimNotas.Active then DM.MemBoletimNotas.Active := False; DM.MemBoletimNotas.Active := True; ProgressBar2.Max := cQuery2.RecordCount; while not cQuery2.EOF do begin DM.MemBoletimNotas.InsertRecord([j, CodBoletim, cQuery2.FieldByName(´DESC_DISCIPLINA´).AsString, cQuery2.FieldByName(´N1´).AsString, cQuery2.FieldByName(´F1´).AsString, cQuery2.FieldByName(´N2´).AsString, cQuery2.FieldByName(´F2´).AsString, cQuery2.FieldByName(´N3´).AsString, cQuery2.FieldByName(´F3´).AsString, cQuery2.FieldByName(´N4´).AsString, cQuery2.FieldByName(´F4´).AsString, cQuery2.FieldByName(´TF´).AsString, cQuery2.FieldByName(´MA´).AsString, cQuery2.FieldByName(´MAX4´).AsString, cQuery2.FieldByName(´MR´).AsString, cQuery2.FieldByName(´MRX6´).AsString, cQuery2.FieldByName(´MF´).AsString ]); ProgressBar2.Position := Prog; Inc(Prog); Inc(j); cQuery2.Next; end;
nesta query
cQuery2.SQL.Clear; cQuery2.SQL.Add(´select * from BOLETIM_NOTAS_FINAL´); cQuery2.SQL.Add(´where COD_BOLETIM = ´ + IntToStr(CodBoletim)); cQuery2.Prepare; cQuery2.Open;
O CodBoletim, vem certo ou seja 1, 2 no caso...
entao se eu vou no IBExpert e uso
select * from BOLETIM_NOTAS_FINAL where COD_BOLETIM = 1
Funciona perfeitamente... ja debuguei e vi que o valor da variavel CodBoletim é passado corretamente
entao o que pode estar acontecendo?
desde ja agradeco
[]s
Titanius
Curtidas 0
Respostas
Titanius
05/01/2005
Só acrescentando.. a cQuery2 eh criada em Runtime
[]s
var cQuery2: TIBQuery; begin cQuery2 := TIBQuery.Create(FrmSelectAluno); cQuery2.Database := DM.IBDatabase1; cQuery2.Transaction := DM.IBTransaction1; . . .
[]s
GOSTEI 0
Bolus
05/01/2005
Caro Colega,
Talvez a solução tenha passado despercebido, por sua preocupação...
No código informado,
acrescente a seguinte linha antes do while
Isso deverá resolver o seu problema......
Espero ter ajudado.....
Talvez a solução tenha passado despercebido, por sua preocupação...
No código informado,
cQuery2.SQL.Clear; cQuery2.SQL.Add(´select * from BOLETIM_NOTAS_FINAL´); cQuery2.SQL.Add(´where COD_BOLETIM = ´ + IntToStr(CodBoletim)); cQuery2.Prepare; cQuery2.Open; j := 0; if DM.MemBoletimNotas.Active then DM.MemBoletimNotas.Active := False; DM.MemBoletimNotas.Active := True; ProgressBar2.Max := cQuery2.RecordCount; while not cQuery2.EOF do begin DM.MemBoletimNotas.InsertRecord([j, CodBoletim, cQuery2.FieldByName(´DESC_DISCIPLINA´).AsString, cQuery2.FieldByName(´N1´).AsString, cQuery2.FieldByName(´F1´).AsString, cQuery2.FieldByName(´N2´).AsString, cQuery2.FieldByName(´F2´).AsString, cQuery2.FieldByName(´N3´).AsString, cQuery2.FieldByName(´F3´).AsString, cQuery2.FieldByName(´N4´).AsString, cQuery2.FieldByName(´F4´).AsString, cQuery2.FieldByName(´TF´).AsString, cQuery2.FieldByName(´MA´).AsString, cQuery2.FieldByName(´MAX4´).AsString, cQuery2.FieldByName(´MR´).AsString, cQuery2.FieldByName(´MRX6´).AsString, cQuery2.FieldByName(´MF´).AsString ]); ProgressBar2.Position := Prog; Inc(Prog); Inc(j); cQuery2.Next; end;
acrescente a seguinte linha antes do while
cQuery2.SQL.Clear; cQuery2.SQL.Add(´select * from BOLETIM_NOTAS_FINAL´); cQuery2.SQL.Add(´where COD_BOLETIM = ´ + IntToStr(CodBoletim)); cQuery2.Prepare; cQuery2.Open; j := 0; if DM.MemBoletimNotas.Active then DM.MemBoletimNotas.Active := False; DM.MemBoletimNotas.Active := True; ProgressBar2.Max := cQuery2.RecordCount; cQuery2.First; <<<<<=============== Acrescente esta linha ******** while not cQuery2.EOF do begin DM.MemBoletimNotas.InsertRecord([j, CodBoletim, cQuery2.FieldByName(´DESC_DISCIPLINA´).AsString, cQuery2.FieldByName(´N1´).AsString, cQuery2.FieldByName(´F1´).AsString, cQuery2.FieldByName(´N2´).AsString, cQuery2.FieldByName(´F2´).AsString, cQuery2.FieldByName(´N3´).AsString, cQuery2.FieldByName(´F3´).AsString, cQuery2.FieldByName(´N4´).AsString, cQuery2.FieldByName(´F4´).AsString, cQuery2.FieldByName(´TF´).AsString, cQuery2.FieldByName(´MA´).AsString, cQuery2.FieldByName(´MAX4´).AsString, cQuery2.FieldByName(´MR´).AsString, cQuery2.FieldByName(´MRX6´).AsString, cQuery2.FieldByName(´MF´).AsString ]); ProgressBar2.Position := Prog; Inc(Prog); Inc(j); cQuery2.Next; end;
Isso deverá resolver o seu problema......
Espero ter ajudado.....
GOSTEI 0
Titanius
05/01/2005
Valeu, agora está pegando todos os registros, porem o RecordCount ainda me retorna 1... mas de resto esta funcionando!
[]s
[]s
GOSTEI 0
Gandalf.nho
05/01/2005
RecordCount não costuma funcionar direito com bancos de dados cliente-servidor como o IB/FB. Se você quiser o total de registros, terá que dar um FetchAll (não recomendado) ou usar SELECT COUNT(*) FROM tabela.
GOSTEI 0