RH+
September 19th, 2009, 07:47 PM
I have this code
Public Function ExecuteDataReaderSP( _
ByVal storedProcedureName As String, _
ByVal ParamArray arrParam() As SqlParameter) As SqlDataReader
Dim reader As SqlDataReader
' Open the connection
If m_cn.State <> ConnectionState.Open Then m_cn.Open()
' Define the command
Dim cmd As New SqlCommand
cmd.Connection = m_cn
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandText = storedProcedureName
' Handle the parameters
If arrParam IsNot Nothing Then
For Each param As SqlParameter In arrParam
cmd.Parameters.Add(param)
Next
End If
' Execute the reader
reader = cmd.ExecuteReader(CommandBehavior.CloseConnection)
Return reader
End Function
how I pass parameters
im using ExecuteDataReaderSP("Name_Of_SP",parameter1,parameter2)
I try various ways to pass the parameters, every time it return a different error.
How is the correct way to pass those parameters?
thanks!
Public Function ExecuteDataReaderSP( _
ByVal storedProcedureName As String, _
ByVal ParamArray arrParam() As SqlParameter) As SqlDataReader
Dim reader As SqlDataReader
' Open the connection
If m_cn.State <> ConnectionState.Open Then m_cn.Open()
' Define the command
Dim cmd As New SqlCommand
cmd.Connection = m_cn
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandText = storedProcedureName
' Handle the parameters
If arrParam IsNot Nothing Then
For Each param As SqlParameter In arrParam
cmd.Parameters.Add(param)
Next
End If
' Execute the reader
reader = cmd.ExecuteReader(CommandBehavior.CloseConnection)
Return reader
End Function
how I pass parameters
im using ExecuteDataReaderSP("Name_Of_SP",parameter1,parameter2)
I try various ways to pass the parameters, every time it return a different error.
How is the correct way to pass those parameters?
thanks!