请教bcb中如何实现sql中的事务处理?

wwwunix 2000-08-28 10:54:00
我想在bcb中实现如下sql功能(事务处理),请问如何实现:
begin work;
insert into table1 values(a,b,c,d);
delete from table2 where a="xx";
if (sqlcode==0)
commit work;
else
rollback work;
...全文
142 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
april_d 2001-08-13
  • 打赏
  • 举报
回复
gz
hhzh426 2000-09-03
  • 打赏
  • 举报
回复
关注!
Slash 2000-09-01
  • 打赏
  • 举报
回复
给你一个用ADO的事务处理例子(Delphi),TDataBase也是类似

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;
yao_yuan 2000-08-28
  • 打赏
  • 举报
回复
用TDataBase的StartTransaction(),Commit()等方法

13,825

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧