使用updatebatch 更新批处理
用cancelbatch 取消批处理
ADO的批更新等效于BDE的缓存更新技术

解决方案 »

  1.   

    to:mrrdh007(木工)
    能否给个简单的例子呀?
      

  2.   

    很简单。
    以query1为例
    1.设置query1的属性:LockType=ltBatchOptimistic;
    2.保存:query1.UpdateBatch(arAll);//或其他参数如arCurrent
    3.取消:query1.CancelBatch(arAll); //arCurrent
    ok?
      

  3.   

    to:twwwh()这样行不行?
    with adoquery1 do
    begin
    close;
    locktyp:=ltbatchoptimistic;
    sql.clear;
    sql.add('insert into table1 select * from table2');
    execsql;
    try
    updatebatch(arall);
    except
    cancelbatch(arall);
    end;
    end;
      

  4.   

    就像楼上两位所说,不过adoquery的cursortype 只能为ctstatic或ctkeyset
      

  5.   

    to:mrrdh007(木工)这样对不对:?
    with adoquery1 do
    begin
      cursorlocation:=clUseServer;
      CursorType:=ctkeySet;
      LockType:=ltBatchOptimistic;
      sql.add('select * from table1');
      open;
      if recordcount>0 then
    begin
      first;
      while not eof do
       begin
       edit;
       fieldbyname('myName').asstring:='myName';
       post;
       next;
       end;//while not eof
    adoconnection1.beginTrans;
    try
      UpdateBatch(arAll);
      adoconnection1.commitTrans;
    except
      CancelBatch(arAll);
      adoconnection1.RollbackTtrans;
    end;//try  
    end;//if recordcount>0
    end;//with adoquery1 do