请大家帮忙看看这段代码哪里有问题,谢谢!
Shared Function Insert(ByVal ConnectionString As String, ByVal SQLString As String) As IntegerDim Connection As SqlConnection = New SqlConnection(ConnectionString)
Dim Command As SqlCommand = New SqlCommand(SQLString, Connection)
Dim Transaction As SqlTransaction
Dim Count As Integer = 0
Connection.Open()
Transaction = Connection.BeginTransaction()
Command.Transaction = Transaction
Try
Count = Command.ExecuteNonQuery()
()
Catch ex As SqlException
MsgBox(ex.ToString())
Catch ex As Exception
MsgBox(ex.ToString())
Finally
Connection.Close()
End Try
Return Count
End Function
学习VB2005中
调用insert后count的返回值说明数据库操作正常,但就是没有添加进数据.
可我的代码里有commit呀
传进的参数为SQLString = "INSERT INTO Table1(aaa,bbb,ccc) VALUES('a2','b2','c2')"
自己研究好几天了,不知道哪里错了.
谢谢了!!!