ACCESS+DELPHI情况,我想求得数据库的第一条记录,和最后一条记录的编号,然后根据记录编号从第一条到最后一条进行循环替换库是的字段数据.
问题1:不知如何求得第一和最后一条的记录号,
问题2:循环如何写,谢了.

解决方案 »

  1.   

    首先:建议采用自动编号主键ID来示标识记录,此为数据表的唯一编号,一般中不存在什么记录号的;
    其次:建议采用主键ID排序,采用UPDATE语句来修改数据,用一个循环也可以,但效率比较低。
      

  2.   

    你说的记录号是指什么?如果你想得到第一条和最后一条记录中字段的内容,用table1.first;table1.last;就可以了!
      

  3.   

    table1.first;
    table1.last;for i:=0 to recordecount-1 do
    begin
    .
    .
    .
    end;while not table1.eof do
    begin
    .
    .
    .
    next;
    end;
      

  4.   

    table1.open;
    table1.First;
    while not table1.eof  do
    begin
      {在此内可以取table1的记录};
    end;
      

  5.   


    with adotable1 do
    begin
      open;
      while not eof do
      begin
        //你的语句
        next;
      end;end;
      

  6.   

    加个自动编号 字段
    select min(自动编号字段) from 表
    select max(自动编号字段) from 表
      

  7.   

    同意: qizhanfeng(glacier) 的观点
    或 然后根据编号order by 
    select * from table order by id while adoquery1.eof do
    begin
      你的语句
      Next;
    end;
      

  8.   

    table1.open;
    table1.First;
    while not table1.eof  do
    begin
     table1.edit;
     table1.fieldbyname('').asstring="内容";  
     table1.post;
     table1. next;
    end;