急急急!!!!!!各位老大们,RecordIndex out of range.错误.......(50分)

  • 主题发起人 主题发起人 softlong
  • 开始时间 开始时间
S

softlong

Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TFrmDZ.CheckBox2Click(Sender: TObject);<br>var<br>&nbsp; i:integer;<br>&nbsp; totalamount,notdzamount,dzamount:real;<br>begin<br>&nbsp; &nbsp; if cxGridDBBandedTableView2.DataController.GetRecordCount&lt;0 then<br>&nbsp; &nbsp; &nbsp; exit;<br>&nbsp; &nbsp; dzamount:=0;<br>&nbsp; &nbsp; notdzamount:=0;<br>&nbsp; &nbsp; totalamount:=0;<br>&nbsp; &nbsp; adoquery1.DisableControls;<br>&nbsp; &nbsp; cxGridDBBandedTableView2.DataController.PostEditingData;<br>&nbsp; &nbsp; if CheckBox2.Checked then<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; adoquery1.First;<br>&nbsp; &nbsp; &nbsp; for i :=0 to cxGridDBBandedTableView2.DataController.GetRecordCount-1 do //<br>&nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; try<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; adoquery1.edit;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; adoquery1.FieldByName('mx_dz').AsString:='1';<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; adoquery1.FieldByName('mx_dzman').asstring:=getusername;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; adoquery1.FieldByName('mx_dzdate').asstring:=formatdatetime('yyyy-mm-dd',getserverdatetime);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; adoquery1.post;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; adoquery1.Next;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; totalamount:=totalamount+strtofloat(cxGridDBBandedTableView2.DataController.Values[i,cxGridDBBandedTableView2mx_amount.Index]);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dzamount:=dzamount+strtofloat(cxGridDBBandedTableView2.DataController.Values[i,cxGridDBBandedTableView2mx_amount.Index]);<br>&nbsp; &nbsp; &nbsp; &nbsp; finally<br><br>&nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; adoquery1.First;<br>&nbsp; &nbsp; &nbsp; adoquery1.EnableControls;<br>&nbsp; &nbsp; end else<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; adoquery1.First;<br>&nbsp; &nbsp; &nbsp; for i :=0 to cxGridDBBandedTableView2.DataController.GetRecordCount-1 do<br>&nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; try<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; adoquery1.edit;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; adoquery1.FieldByName('mx_dz').AsString:='0';<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; adoquery1.FieldByName('mx_dzman').asstring:='';<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; adoquery1.FieldByName('mx_dzdate').asstring:='';<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; adoquery1.Post;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; adoquery1.Next;<br>&nbsp; &nbsp; &nbsp; &nbsp; except<br><br>&nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; adoquery1.First;<br>&nbsp; &nbsp; &nbsp; adoquery1.EnableControls;<br>&nbsp; &nbsp; &nbsp; totalamount:=totalamount+strtofloat(cxGridDBBandedTableView2.DataController.Values[i,cxGridDBBandedTableView2mx_amount.Index]);<br>&nbsp; &nbsp; &nbsp; notdzamount:=notdzamount+strtofloat(cxGridDBBandedTableView2.DataController.Values[i,cxGridDBBandedTableView2mx_amount.Index]);<br><br>&nbsp; &nbsp; end;<br><br>&nbsp; &nbsp; edit1.Text:=floattostr(totalamount);<br>&nbsp; &nbsp; edit2.Text:=floattostr(dzamount);<br>&nbsp; &nbsp; edit3.Text:=floattostr(notdzamount);<br><br><br>代码很简单,执行时,就是checkbox.checked=false时,抱:RecordIndex out of range.错误.或许adoquery1.next不该写,但不知怎么写.<br>在线等...谢谢!!!!!!!
 
看上去好像没有错误,不知道你的cxGridDBBandedTableView2.DataController.getRecordCount 和你的adoquery1.recordcount 是否相同,不同的话就有问题啦。
 
非常感谢!
 

Similar threads

S
回复
0
查看
870
SUNSTONE的Delphi笔记
S
I
回复
0
查看
2K
import
I
I
回复
0
查看
3K
import
I
W
回复
7
查看
483
wangqinyun2000
W
后退
顶部