Public Function Trans (Byval strSQL1 As String, Byval strSQL2 As String ,Byval strSQL3 As String ,Byval strSQL4 As String ,Byval strSQL5 As String , _
Byval strSQL6 As String ,Byval strSQL7 As String ,Byval strSQL8 As String ,Byval strSQL9 As String ,Byval strSQL10 As String ) As Boolean
Try
Dim cmd As New SQLCommand
cmd.C
cmd.CommandText = "Begin Transaction;" _
& strSQL1 & ";" _
& strSQL2 & ";" _
& strSQL3 & ";" _
& strSQL4 & ";" _
& strSQL5 & ";" _
& strSQL6 & ";" _
& strSQL7 & ";" _
& strSQL8 & ";" _
& strSQL9 & ";" _
& strSQL10 & ";" _
& "Commit Transaction "
cmd.ExecuteNonQuery
Return True
Catch ex As Exception
cmd.CommandText = "RollbackTrans"
Return False
MessageBox.Show("向服务器提交数据错误!","提示",MessageBoxButtons.OK)
End Try
End Function
报错如下图:
此主题相关图片如下:1.png