if (QrySingle.State in [dsEdit,dsInsert]) then
if not PostQry(QrySingle) then Exit;
if QrySingle.UpdatesPending then //empty is not save!!!!
begin
try
QrySingle.Database.StartTransaction;
QrySingle.ApplyUpdates;
QrySingle.Database.Commit;
QrySingle.CommitUpdates;
Application.MessageBox(成功保存數據,提示,48);
SaveSuccess:=True;
except
QrySingle.Database.Rollback;
SaveSuccess:=False;
Application.MessageBox(系統數據錯誤,請聯絡系統管理員,提示,48);
end;
FormMode:=FmBrowse;
end;
end;
以上為BDE更新程序,應該怎麼寫ADO更新呢?
if (QrySingle.State in [dsEdit,dsInsert]) then
if QrySingle.recordcount<> 0 then //empty is not save!!!!
begin
try
ADOConnection1.BeginTrans; //開始事務
QrySingle.UpdateBacth;
ADOConnection1.CommitTrans; //提交事務
Application.MessageBox(成功保存數據,提示,48);
SaveSuccess:=True;
except
ADOConnection1.RollbackTrans; //事務回滾
SaveSuccess:=False;
Application.MessageBox(系統數據錯誤,請聯絡系統管理員,提示,48);
end;
FormMode:=FmBrowse;
end;
end;