我要的就是看數據集有沒有被更該,在決定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; 為批量更新
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;正确的
以为是
ADOTABLE有个CanModify属性
是决定数据集是否可写的
你试试
還有怎樣確認這個數據集,有沒有被修改(不能用adoquery1.Modified)
Modified
表示被更改
下面是我的代碼
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;
為批量更新
adoquery1.CursorType:=ctStaic;if adoquery1.Modified then
begin
if messagebox(handle,'放棄未保存的修改?','警告',MB_YESNO)=ID_YES then ADOQuery1.CancelBatch(arAll)
else
ADOQuery1.UpdateBatch(arAll);
end;正确的
locktype属性设为ltOptimistic说错了吧!
如果为批量更新
locktype的属性值必须为:ltbatchoptimistic
CursorType的属性值必须为:ctKeySet或ctStatic