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;
评论
发表评论

您还没有登录,请登录后发表评论

kenter1643
搜索本博客
博客分类
最近加入圈子
存档
最新评论