您的位置:首页 > 编程语言 > Delphi

ADO的事务处理例子(Delphi)

2008-05-26 09:01 375 查看
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;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: