用adocon/adoquery/datasource/dbgrid的组合从数据库读数据,在DBGRID最前面一列加一列序号,在adoquery的CalcFields中写:adoquery.FieldByName('num').asinteger:=adoquery.RecNo;
if adoquery.bof then
adoquery.FieldByName('num').asinteger :=1;
在dbgrid的最后一个数也变成1了,这该怎么办???
SQL语句 创建临时字段 RRECNO 并保存创建临时表 TEMP01
select top 10 0 as Rrecno ,rname,rtel into temp01
from LinkEyeeInfo
select * from temp01 drop table temp01
事件:
procedure TForm1.FormShow(Sender: TObject);
begin
self.ADOQuery1.First;
while not self.ADOQuery1.Eofdo
begin
self.ADOQuery1.Edit;
self.ADOQuery1.FieldByName('RRecno').AsInteger := Self.ADOQuery1.RecNo;
self.ADOQuery1.Post;
self.ADOQuery1.Next;
end;