老师好,两个数据源,分别是 y1 与y2, 只有当 bo 与 boo 都为true的时候, 才执行事务。 下面的代码有没有问题? 谢谢老师
dim cmd1 as new sqlcommand
cmd1.Conn ectionName=“Y1”
dim cmd2 as new sqlcommand
cmd2.Conn ectionName=“Y2”
dim bo as boolen=true
dim boo as boolen=true
Try
cmd1.BeginTransaction
cmd1.CommandText = "---------")
cmd1.ExecuteNonQuery
bo = True
Catch ex As Exception
bo = False
cmd1.Rollback
Return
End Try
-----------------------------------------
Try
cmd2.BeginTransaction
cmd2.CommandText = "---------")
cmd2.ExecuteNonQuery
boo = True
Catch ex As Exception
boo = False
cmd2.Rollback
Return
End Try
----------------------------
if bo=true andalso boo=too then
cmd1.Commit
cmd2.Commit
end if
[此贴子已经被作者于2024/6/14 15:58:14编辑过]