2007-10-22
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;
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;
发表评论
- 浏览: 25339 次
- 性别:

- 来自: 珠海

- 详细资料
搜索本博客
最近加入圈子
最新评论
-
一个自己写的很简陋的php ...
在构想 tag的中文映射如何构建 期待能做到足够的智能化
-- by kenter1643 -
一个用js+div实现的拖拽, ...
更多基于jquery的效果demohttp://interface.eyecon ...
-- by kenter1643 -
使用 jQuery(Ajax)/PHP/My ...
php-excel是一个非常简单,用于生成excel文档的php函数库。项目站点 ...
-- by kenter1643 -
DELPHI VCL组件 TTreeList ...
没有安装成功: Compile 时报 File not find:'bmp.r ...
-- by newchina -
vsftpd的配置
useradd -d 目录 用户名 passwd 用户 chown 用户名 ...
-- by kenter1643






评论排行榜