Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. SqlDataReader with multiple result sets

SqlDataReader with multiple result sets

Scheduled Pinned Locked Moved C#
questiondatabase
5 Posts 3 Posters 10 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Richard Andrew x64R Offline
    Richard Andrew x64R Offline
    Richard Andrew x64
    wrote on last edited by
    #1

    When I execute a stored procedure with SqlCommand.ExecuteReader, how do I access the specific result set I need in the case that the stored procedure returns more than one result set?

    The difficult we do right away... ...the impossible takes slightly longer.

    P OriginalGriffO 2 Replies Last reply
    0
    • Richard Andrew x64R Richard Andrew x64

      When I execute a stored procedure with SqlCommand.ExecuteReader, how do I access the specific result set I need in the case that the stored procedure returns more than one result set?

      The difficult we do right away... ...the impossible takes slightly longer.

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      My understanding of this is you can use NextResult to get the next resultset. As it's a firehose, you can't go backwards unfortunately.

      Advanced TypeScript Programming Projects

      Richard Andrew x64R 1 Reply Last reply
      0
      • P Pete OHanlon

        My understanding of this is you can use NextResult to get the next resultset. As it's a firehose, you can't go backwards unfortunately.

        Advanced TypeScript Programming Projects

        Richard Andrew x64R Offline
        Richard Andrew x64R Offline
        Richard Andrew x64
        wrote on last edited by
        #3

        Thanks, Pete!

        The difficult we do right away... ...the impossible takes slightly longer.

        1 Reply Last reply
        0
        • Richard Andrew x64R Richard Andrew x64

          When I execute a stored procedure with SqlCommand.ExecuteReader, how do I access the specific result set I need in the case that the stored procedure returns more than one result set?

          The difficult we do right away... ...the impossible takes slightly longer.

          OriginalGriffO Offline
          OriginalGriffO Offline
          OriginalGriff
          wrote on last edited by
          #4

          As Pete says, the reader doesn't "rewind" - so I'd probably prefer to use a DataAdapter and fill a Dataset instead of using a DataReader. That way all of the data for all of the sets is available for random access as needed.

          "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

          "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
          "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

          Richard Andrew x64R 1 Reply Last reply
          0
          • OriginalGriffO OriginalGriff

            As Pete says, the reader doesn't "rewind" - so I'd probably prefer to use a DataAdapter and fill a Dataset instead of using a DataReader. That way all of the data for all of the sets is available for random access as needed.

            "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

            Richard Andrew x64R Offline
            Richard Andrew x64R Offline
            Richard Andrew x64
            wrote on last edited by
            #5

            Good point, Griff! I didn't know that option existed!

            The difficult we do right away... ...the impossible takes slightly longer.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups