The following function calls a stored procedure and inputs vars. from my form. I am new to using the data blocks and not quite sure how to use the ParameterDirection
Shared Function SelectOpinionCodes(ByVal coID As Integer, ByVal coName As String, ByVal coDescription As String) As DataSet
Dim sqlParams(4) As SqlClient.SqlParameter
If coName Is Nothing Then
sqlParams(0) = New SqlParameter("@name", coName)
Else
sqlParams(0) = New SqlParameter("@name", DBNull.Value)
End If
If coDescription Is Nothing Then
sqlParams(1) = New SqlParameter("@description", coDescription)
Else
sqlParams(1) = New SqlParameter("@description", DBNull.Value)
End If
If coID = Nothing Then
sqlParams(2) = New SqlParameter("@id", coID)
Else
sqlParams(2) = New SqlParameter("@id", DBNull.Value)
End If
sqlParams(3).Direction = ParameterDirection.InputOutput
Return SqlHelper.ExecuteDataset(conString, CommandType.StoredProcedure, "usp_CodesRulesSelect", sqlParams)
Return sqlParams(6).Value
End Function
Is producing the following error:
Object reference not set to an instance of an object.
Line 33: sqlParams(2) = New SqlParameter("@id", DBNull.Value)
Line 34: End If
Line 35: sqlParams(3).Direction = ParameterDirection.InputOutput
Line 36: Return SqlHelper.ExecuteDataset(conString, CommandType.StoredProcedure, "usp_CodesRulesSelect", sqlParams)
Line 37: Return sqlParams(6).Value