Retrieving output parameters with ExecuteReader() instead of

Retrieving output parameters with ExecuteReader() instead of

am 26.01.2008 09:55:20 von msch.prv

Hi, I just wonder if it is possible to retrieve sproc output
parameters with the ExecuteReader() method. I have some code that
works fine with the ExecuteNonQuery() variant, but fails with the
reader approach.

An article on 4 Guys by Scott Mitchell:
http://aspnet.4guysfromrolla.com/demos/printPage.aspx?path=/ articles/062905-1.aspx
seems to suggest this is feasible. For some reason, I cannot run
these examples: the output parameters return nothing. When
ExecuteNonQuery() is substituted back, parameter retrieving works.

Has anyone successfully used the ExecuteReader appproach to extract
output parameters? TIA for any pointers.

Re: Retrieving output parameters with ExecuteReader() instead of

am 26.01.2008 11:14:16 von msch.prv

Ok, I found the error. Sproc output parameters can be extracted with
ExecuteReader(). However, the SqlDataReader must be closed before the
output parameters can be retrieved.

Re: Retrieving output parameters with ExecuteReader() instead of ExecuteNonQuery

am 27.01.2008 02:08:26 von DFS

it doesn't need to be closed, you just need to read all result sets
before accessing the parameters, as their values come after the last
result set. calling close process all result sets.

-- bruce (sqlwork.com)

msch.prv@gmail.com wrote:
> Ok, I found the error. Sproc output parameters can be extracted with
> ExecuteReader(). However, the SqlDataReader must be closed before the
> output parameters can be retrieved.