+ -
当前位置:首页 → 问答吧 → 怎么把连续的数字插入到delphi的dbgrid中

怎么把连续的数字插入到delphi的dbgrid中

时间:2011-12-22

来源:互联网

我在access中增加了"排名"字段,但里面没有数据,表中数据已导入到dbgrid中,里面也有"总分"字段,现在我想通过一个button组件来实现把1到50的数字(总共50个记录)添加到那个"排名"字段中,使他是根据总分来排名的,大家有没有什么办法来实现?最好给出代码。

作者: mingrenhappy   发布时间: 2011-12-22

var
  ds: TDataSet;
  s:string;
  i:Integer;
begin
  i:=0;
  ds:= self.DBGrid1.DataSource.DataSet;
  ds.First;
  while not ds.Eof do
  begin
  ds.Edit;
  ds.FieldByName('总分').AsString:=IntToStr(i);
  Inc(i);
  ds.next;
  Application.ProcessMessages;
  //ds.Post; //这个是提交数据库
  end;
  ShowMessage(IntToStr(i)+'行记录设置好序号');
end;

作者: zhangqiwen   发布时间: 2011-12-22

热门下载

更多