When using a DataReader
object to access data from a database (such as SQL Server) through stored procedures, any output parameter added to the Command object before executing are not being filled after reading. I can read row data just fine, as well as all input parameters, but not output ones.
Asked
Active
Viewed 6,486 times
10

Tim B
- 40,716
- 16
- 83
- 128

Sean Hanley
- 5,677
- 7
- 42
- 53
1 Answers
16
This is due to the "by design" nature of DataReaders. Any parameters marked as ParameterDirection.Output
won't be "filled" until the DataReader has been closed. While still open, all Output parameters will more than likely just come back null
.
The full Microsoft KB article concerning this can be viewed here.

Sean Hanley
- 5,677
- 7
- 42
- 53