vb初学者
Public Shared Function DeleteUserReportAuthorization(ByVal index As Integer, Optional ByVal trans As SqlTransaction = Nothing) As Integer
Dim retVal As Integer
Dim conPortal As SqlConnection
Dim sqlCmd As SqlCommand
Dim outerTrans As Boolean
If trans Is Nothing Then
outerTrans = False
conPortal = New SqlConnection(HerpData.ConnectionString(HerpSubSystems.HerpCM))
sqlCmd = New SqlCommand("UserReportAuthorizationsDeleteUserReportAuthorization", conPortal)
Else
outerTrans = True
conPortal = trans.Connection
sqlCmd = New SqlCommand("UserReportAuthorizationsDeleteUserReportAuthorization", conPortal, trans)
End If
sqlCmd.CommandType = CommandType.StoredProcedure
sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int).Direction = ParameterDirection.ReturnValue
sqlCmd.Parameters.Add("@ura_id", index)
If conPortal.State = ConnectionState.Closed Then
conPortal.Open()
End If
Try
sqlCmd.ExecuteNonQuery()
Catch ex As Exception
If outerTrans = False Then conPortal.Close()
Return -1
End Try
retVal = Fix(sqlCmd.Parameters("@RETURN_VALUE").Value)
If outerTrans = False Then conPortal.Close()
Return retVal
End Function
Optional ByVal trans As SqlTransaction = Nothing) As Integer
这句是什么意思,为什么要加上事物来做为参数