-- 作者:yedaoan
-- 发布时间:2013/12/26 9:49:00
-- 事务处理函数,快完工了
做了个事务处理函数,提交没有问题了,但是事务回滚这段,还有问题
如果用 cmd.CommandText = "Begin Transaction;" & strSQL & "RollbackTrans 不知能不能回滚,不知道这样写是不是对的?
如果用 cmd.CommandText = "RollbackTrans 又无法通过编译,请指教
Try Dim cmd As New SQLCommand Dim strSQL As String cmd.C For i As Integer =0 To args.length-1 If args(i) Is Nothing Then Exit For Else strSQL=strSQL & args(i) & ";" End If Next cmd.CommandText = "Begin Transaction;" & strSQL & "Commit Transaction" cmd.ExecuteNonQuery Return True Catch ex As Exception cmd.CommandText = "Begin Transaction;" & strSQL & "RollbackTrans" \'cmd.CommandText = "RollbackTrans" cmd.ExecuteNonQuery \'cmd.RollbackTrans Return False MessageBox.Show("向服务器提交数据错误!","提示",MessageBoxButtons.OK) End Try
[此贴子已经被作者于2013-12-26 9:51:22编辑过]
|