Retrieving output parameters with ExecuteReader() instead ofExecuteNonQuery

Discussion in 'ASP .Net' started by msch.prv@gmail.com, Jan 26, 2008.

  1. Guest

    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.
    , Jan 26, 2008
    #1
    1. Advertising

  2. Guest

    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.
    , Jan 26, 2008
    #2
    1. Advertising

  3. bruce barker Guest

    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)

    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.
    bruce barker, Jan 27, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Julian Bowes
    Replies:
    0
    Views:
    669
    Julian Bowes
    Jul 1, 2003
  2. karim
    Replies:
    6
    Views:
    7,776
    karim
    Aug 14, 2003
  3. JD Drewes

    Odd ExecuteReader Error

    JD Drewes, Oct 28, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    387
    JD Drewes
    Oct 28, 2003
  4. PinkGuava

    Retrieving Output Parameters and Recordset

    PinkGuava, Sep 16, 2004, in forum: ASP General
    Replies:
    1
    Views:
    376
    Bob Barrows [MVP]
    Sep 16, 2004
  5. stjulian
    Replies:
    1
    Views:
    176
    Bob Barrows [MVP]
    Feb 8, 2006
Loading...

Share This Page