看上面的语句,似乎更改同一字段为相同的内容。如果真的同一字段批量更改为同一内容,为什么不用SQL语句?Update 表名 set 字段名=新值 where 条件

解决方案 »

  1.   

    改为如下:
    adotable1.first;    //  added statement
    for i:=1 to adotable1.recordcount do
    begin
      with adotable1 do
      begin
        edit;
        adotable1.fields[1]='更新‘;
        post;
        next;   //  added statement
      end;
    end;
      

  2.   

    adotable1.first;
    while not adotable1.Eof do
    begin
      with adotable1 do
      begin
        edit;
        adotable1.fields[1]='更新‘;
        post;
        next;
      end;
    end;
      

  3.   

    to:fmj(fmjstone)
    因为我的adotable 中,使用了过滤条件,不方便使用sql语句。
    谢谢几位的关注,我试试,如果能行,一定给分
      

  4.   

    你的代码:
    for i:=1 to adotable1.recordcount do
    begin
      with adotable1 do
      begin
        edit;
        adotable1.fields[1]='更新‘;
        post;
      end;
    end;你没有先用AdoTable.First才出现越界错误.而且你还没有用Next移动这个指针,上面程序的结果是数据库的指针已经出界(可能是被你前面的程序改的)或者反复改相同的一条纪录.skimwater(掠水惊鸿)和wangxd1976(西门吹雪) 的例子应该没有问题!!