B
Brian
I have a public function that I want to pass in a
StoredProc name and any parmaters that the proc might
need...
Here is my function...
Public Function FillDataReader(ByVal currentStoredProc As
String) As SqlDataReader
' Create Instance of Connection and Command
Object
Dim myConnection As SqlConnection = New
SqlConnection(ConfigurationSettings.AppSettings
("ConnectionString"))
'Dim myCommand As SqlCommand = New SqlCommand
("INV_SEL_CURRENT_VEHICLE", myConnection)
myConnection.Open()
Dim Command As New SqlCommand
(currentStoredProc, myConnection)
' Mark the Command as a SPROC
Command.CommandType =
CommandType.StoredProcedure
Return Command.ExecuteReader
End Function
To call the function I do this...
Public Function GetCurrentVehicle(ByVal
passedInVehicleID As Integer) As SqlDataReader
Return FillDataReader("INV_SEL_CURRENT_VEHICLE")
End Function
Any ideas how to pass 0, 1 or more parameters that any
given proc might need?
I've seen how to do it for a dataSet, but I want to do it
for a dataReader...
Thanks in advance!
StoredProc name and any parmaters that the proc might
need...
Here is my function...
Public Function FillDataReader(ByVal currentStoredProc As
String) As SqlDataReader
' Create Instance of Connection and Command
Object
Dim myConnection As SqlConnection = New
SqlConnection(ConfigurationSettings.AppSettings
("ConnectionString"))
'Dim myCommand As SqlCommand = New SqlCommand
("INV_SEL_CURRENT_VEHICLE", myConnection)
myConnection.Open()
Dim Command As New SqlCommand
(currentStoredProc, myConnection)
' Mark the Command as a SPROC
Command.CommandType =
CommandType.StoredProcedure
Return Command.ExecuteReader
End Function
To call the function I do this...
Public Function GetCurrentVehicle(ByVal
passedInVehicleID As Integer) As SqlDataReader
Return FillDataReader("INV_SEL_CURRENT_VEHICLE")
End Function
Any ideas how to pass 0, 1 or more parameters that any
given proc might need?
I've seen how to do it for a dataSet, but I want to do it
for a dataReader...
Thanks in advance!