关于事务处理的问题,请各位进来看看,谢谢!!

liujianghong 2003-10-31 10:17:33
有这样一个事务处理程序:
dim conn as new adodb.connection
on error resume next
conn.open strConn
conn.begin
Conn.BeginTrans
conn.execute "insert into tableAA"
do while true
conn.execute "insert into tableBB"
if 条件 then exit do
loop

if err.number=0 then
Conn.CommitTrans
else
Conn.RollbackTrans
end if

对于上面的程序,如果在循环部分出错了. 问题: 事务回滚是怎样的.是回滚当前语句还是回滚全部已执行的循环语句呢.
...全文
64 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
itlive 2003-11-03
  • 打赏
  • 举报
回复
当然是全部了
yoki 2003-11-03
  • 打赏
  • 举报
回复
你需要回滚到哪?你的是全部回滚,即只要出错那么不会插入任何纪录

部分回滚需要将事务开始及提交语句放在循环里面,如:
conn.execute "insert into tableAA"
do while true
Conn.BeginTrans
conn.execute "insert into tableBB"
if 条件 then exit do
if err.number=0 then
Conn.CommitTrans
else
Conn.RollbackTrans
end if
loop

cryptonym 2003-11-03
  • 打赏
  • 举报
回复
回滚这么多
conn.execute "insert into tableAA"
do while true
conn.execute "insert into tableBB"
if 条件 then exit do
loop

sunnyBelt 2003-11-03
  • 打赏
  • 举报
回复
是全部的。因为事物在执行的时候对数据库的更新并没有应用到数据库中去,当回滚的时候就把内存中的更改取消掉了。
qjqmoney 2003-10-31
  • 打赏
  • 举报
回复
事务会回滚所有BeginTrans到RollbackTrans之间的操作。
liujianghong 2003-10-31
  • 打赏
  • 举报
回复
怎么没有人帮帮呀

7,763

社区成员

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

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