一般来说,数据引擎如:bde可以自已管理事务的,当成功处理数据后,事务就会自动提交,出错就会回滚。当然你也可以用
Database1.StartTransaction ;
Database1.Commit;
Database1.Rollback;
来控制:如:
procedure TForm1.ApplyButtonClick(Sender: TObject);begin
with CustomerQuery do
begin
Database1.StartTransaction;
try
ApplyUpdates; {try to write the updates to the database};
Database1.Commit; {on success, commit the changes};
except
Database1.Rollback; {on failure, undo the changes};
raise; {raise the exception to prevent a call to CommitUpdates!}
end;
CommitUpdates; {on success, clear the cache}
end;end;
Database1.StartTransaction ;
Database1.Commit;
Database1.Rollback;
来控制:如:
procedure TForm1.ApplyButtonClick(Sender: TObject);begin
with CustomerQuery do
begin
Database1.StartTransaction;
try
ApplyUpdates; {try to write the updates to the database};
Database1.Commit; {on success, commit the changes};
except
Database1.Rollback; {on failure, undo the changes};
raise; {raise the exception to prevent a call to CommitUpdates!}
end;
CommitUpdates; {on success, clear the cache}
end;end;
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货