频道分类

Delphi ADO的事务处理例子

作者:admin 来源: 日期:2020/3/31 18:55:03 人气: 标签:

 
ADO的事务处理例子(Delphi)
ADOConnection1.BeginTrans;   //开始事务
try
with ADOCommand1 do
begin
Connection:=ADOConnection1;
commandtext:='update [country] set [population]=10000 where [name=''Venezuela''';//正确的SQL语句
Execute;
CommandText:='Wrong SQL Command';//错误的SQL Execute;
ADOConnection1.CommitTrans; //提交事务end;
except on E:
Exception do
begin
ADOConnection1.RollbackTrans; //如有异常,事务回滚ShowMessage(E.Message); end end;
end;
————————————————

原文链接:https://blog.csdn.net/zzflover/article/details/2481093