ADO.NET transaction i update metode?
Hejsa....Hvorfor vil denne her, metode ikke opdatere? Den kommer ikke med nogen fejl?
Public Sub UpdateUserData(ByVal iUsers As Integer, ByVal sCompany As String, ByVal sUserName As String, ByVal sEmail As String, ByVal sPassword As String, ByVal sUserRights As String, ByVal sAddedDate As String)
Dim oDataAccess As New DbObject()
Dim oConnection As SqlConnection = oDataAccess.GetConnection()
Dim oCommand As New SqlCommand()
Dim oTrans As SqlTransaction
Try
oTrans = oConnection.BeginTransaction
With oCommand
.CommandText = "sp_UserUpdate"
.CommandType = CommandType.StoredProcedure
.Parameters.Add("@UserID", SqlDbType.Int, 4).Value = iUsers
.Parameters.Add("@Company", SqlDbType.NVarChar, 50).Value = sCompany
.Parameters.Add("@Name", SqlDbType.NVarChar, 50).Value = sUserName
.Parameters.Add("@Email", SqlDbType.NVarChar, 50).Value = sEmail
.Parameters.Add("@Password", SqlDbType.NVarChar, 50).Value = sPassword
.Parameters.Add("@UserRights", SqlDbType.Int, 4).Value = sUserRights
.Parameters.Add("@AddedDate", SqlDbType.DateTime, 8).Value = sAddedDate
.Connection = oTrans.Connection
.Transaction = oTrans
End With
oTrans.Commit()
Catch 'exc As DataException
oTrans.Rollback()
Throw 'New DataException("Der opstod en fejl i UpdateUserData metoden", exc)
Finally
If oConnection.State <> ConnectionState.Closed Then
oConnection.Close()
End If
End Try
End Sub
mvh
DK
