General information
Title:
Loading a DataReader
I am trying to load a DataReader from a SQLServer stored procedure. I have to following code:
Dim objConnection As SqlConnection
Dim objCommand As SqlCommand
Dim objParameter As SqlParameter
Dim objDR As SqlDataReader
Try
objConnection = New SqlConnection(DBConnectionName)
objConnection.Open()
objCommand = New SqlCommand(LoadPagedStoredProcedure, objConnection)
objCommand.CommandType = CommandType.StoredProcedure
... Set Parameters Here ...
objDR = objCommand.ExecuteReader(CommandBehavior.CloseConnection)
Catch objException As Exception
mObjException = objException
Catch objSQLException As SqlException
mObjException = objSQLException
End Try
Return objDR
There are no errors, but the DataReader is empty. When I change the DataReader to a DataSet and change the ExecuteReader to a Fill, all works perfectly.
What am I doing wrong?
TIA
Rex
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only