multiple result sets vs mulitple data readers RRS feed

  • Question

  • User863284803 posted

    Ok - I am just wondering...

    Would it be better to have a sp return multiple result sets and use NextResult()  or have subsequent call to dr.execute.... () and hadle one result at a time?

    To me using nextResult() on a multiresult datareader would be cleaner and easier - but it does not seem to be very "atomized".  I guess I am wondering can the cost of executing multiple commands be neglected?   Seems like executing multiple commands and receiving a single result set would also be easier to read/test/understand.

    Friday, June 4, 2010 2:07 AM


  • User-821857111 posted

    It would be more performant to use NextResult() because you are making only one call to the database. Ideally, you should limit your "out-of-process" calls. You could use a wrapper procedure per page, which would be responsible for retrieving all data for that page. However, there is extra maintenance overhead doing it this way. For example, if you add a new data-related feature to a number of pages, you have to remember to add the SP to the wrapper proc for each page. I think I would prefer to put the data call in the code-behind of a user control for that.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, June 4, 2010 2:25 AM