代码如下:
  while not query.eof do
  begin
     s:='update table set ....'
     query.sql.clear;
     query.sql.add(s);
     query.execsql;
     query.next;   //到这一步就异常,提示不能操作关闭的数据集
  end;
请大家看看有什么问题

解决方案 »

  1.   

    你用同一个query操作?一个查询一个更新?
    用两个试试
    ----------------------------------------------------------------
                 花自飘零水自流,一种相思,两处闲愁。
                   此情无计可消除,才下眉头,又上心头。
    ----------------------------------------------------------------
      

  2.   

    query.execsql;  ——> query.open 或者query.active := true
      

  3.   

    操作之前应该加一句,query.open把数据集打开
      

  4.   

    执行的SQL语句不能和数据集用一个query
      

  5.   

    update yb1 set c4=c4+ (select c2 from
       (select c1c2c3.c1,c1c2c3.c2 from c1c2c3,yb1 where yb1.c1=c1c2c3.c1
          union
        select c1,0 as c2 from yb1 where c1 not in
           (select c1 from c1c2c3)) b
      where yb1.c1=b.c1);数据更新用上面这里,没必要while not query.eof do.
      

  6.   

    晕死,update 又不返回数据集,在调用 Next 当然出错了
      

  7.   

    呵呵 在使用了query.execsql 之后,数据集就已经关闭了,并不会返回数据集,所以要再次操作,那还得再次打开 open,然后再edit,就可以操作了!