关于 mycon.BeginTransaction()问题
Public Function myExecSQL(ByVal constr As String, ByVal mysql As String) As String
Dim mycon As New SqlConnection(constr)
Dim mycom As New SqlCommand(mysql, mycon)
Dim myTran As SqlTransaction
mycon.Open()
myTran = mycon.BeginTransaction()
Try
mycom.ExecuteNonQuery()
myTran.Commit()
Catch ex As Exception
myTran.Rollback()
Return "False "
Exit Function
Finally
mycon.Close()
End Try
Return "True "
End Function
上面的过程哪里出错了?一执行到mycom.ExecuteNonQuery()这里好像就出错了。
------解决方案--------------------看看sql语句是不是对了
------解决方案--------------------...
Try
mycom.Transaction = myTran '这里加上这个
mycom.ExecuteNonQuery()
myTran.Commit()
...