怎樣設置ADOQUERY數據集是可讀和可寫

解决方案 »

  1.   

    是我看错啦
    以为是
    ADOTABLE有个CanModify属性
    是决定数据集是否可写的
    你试试
      

  2.   

    這是個只讀屬性,不能改變
    還有怎樣確認這個數據集,有沒有被修改(不能用adoquery1.Modified)
      

  3.   

    是否被更改是
    Modified
      

  4.   

    Post之前如果为true
    表示被更改
      

  5.   

    我要的就是看數據集有沒有被更該,在決定post不post,因為我用的是批量更新
    下面是我的代碼
    procedure Tfrmdept.FormClose(Sender: TObject; var Action: TCloseAction);
    begin
    if adoquery1.Modified then
    begin
    if messagebox(handle,'放棄未保存的修改?','警告',MB_YESNO)=ID_YES  then
    action:=cafree
    else
    action:=canone ;
    end
    else
    action:=cafree;
    end;
    我設置
    adoquery1.LockType:=ltbatchoptimistic;
    adoquery1.CursorType:=ctkeyset;
    為批量更新
      

  6.   

    adoquery1.LockType:=ltbatchoptimistic;
    adoquery1.CursorType:=ctStaic;if adoquery1.Modified then
    begin
    if messagebox(handle,'放棄未保存的修改?','警告',MB_YESNO)=ID_YES  then ADOQuery1.CancelBatch(arAll)
    else
    ADOQuery1.UpdateBatch(arAll);
    end;正确的
      

  7.   

    回复人: Tensionli() 
    locktype属性设为ltOptimistic说错了吧!
    如果为批量更新
    locktype的属性值必须为:ltbatchoptimistic
    CursorType的属性值必须为:ctKeySet或ctStatic