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-Ouput Parameter And SqlConnection

SqlDataReader-Ouput Parameter And SqlConnection

Scheduled Pinned Locked Moved C#
databasewpfwcfcomhelp
7 Posts 4 Posters 0 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.
  • N Offline
    N Offline
    Nagaraj Muthuchamy
    wrote on last edited by
    #1

    Hi, I am using a procedure which selects some rows and handles a output parameter. I am executing this procedure using SqlDataReader. Problem Is , If Connection is kept open after ExecuteReader(), Sql Reader is working fine and able to do data binding. But, output parameter is returing null value. If Connection is closed, I am able to get the correct output parameter value. But, SqlDataReader is not working. Any Ideas to make both working regardless of connection status. Thanks, Nagaraj

    Umbraco Developer

    A 1 Reply Last reply
    0
    • N Nagaraj Muthuchamy

      Hi, I am using a procedure which selects some rows and handles a output parameter. I am executing this procedure using SqlDataReader. Problem Is , If Connection is kept open after ExecuteReader(), Sql Reader is working fine and able to do data binding. But, output parameter is returing null value. If Connection is closed, I am able to get the correct output parameter value. But, SqlDataReader is not working. Any Ideas to make both working regardless of connection status. Thanks, Nagaraj

      Umbraco Developer

      A Offline
      A Offline
      Ashfield
      wrote on last edited by
      #2

      You can't. You only get the ouput parameter back when you close the connection. Its always been that way.

      Bob Ashfield Consultants Ltd Proud to be a 2009 Code Project MVP

      N 1 Reply Last reply
      0
      • A Ashfield

        You can't. You only get the ouput parameter back when you close the connection. Its always been that way.

        Bob Ashfield Consultants Ltd Proud to be a 2009 Code Project MVP

        N Offline
        N Offline
        Nagaraj Muthuchamy
        wrote on last edited by
        #3

        Thanks Bob, My code is fetching the records for GridView Binding (for the selected PageIndex) and total results in single call to database. I am returing SqlReader from DAC to BusinessLayer and to Code file from there. Is there any better way to achive this? Thanks again Nagaraj

        Umbraco Developer

        C A 2 Replies Last reply
        0
        • N Nagaraj Muthuchamy

          Thanks Bob, My code is fetching the records for GridView Binding (for the selected PageIndex) and total results in single call to database. I am returing SqlReader from DAC to BusinessLayer and to Code file from there. Is there any better way to achive this? Thanks again Nagaraj

          Umbraco Developer

          C Offline
          C Offline
          Coding C
          wrote on last edited by
          #4

          DataReader needs open connection. Better you use DataSet, DataAdapter.

          Coding C# www.excitetemplate.com

          1 Reply Last reply
          0
          • N Nagaraj Muthuchamy

            Thanks Bob, My code is fetching the records for GridView Binding (for the selected PageIndex) and total results in single call to database. I am returing SqlReader from DAC to BusinessLayer and to Code file from there. Is there any better way to achive this? Thanks again Nagaraj

            Umbraco Developer

            A Offline
            A Offline
            Ashfield
            wrote on last edited by
            #5

            You could use a dataset and fill that, I think you would then get your output parameter straight away - not 100% sure though, I haven't tried it. Alternatively, return 2 recordsets and use a dataadaptor to fill a dataset, you then should get what would have been the output param in its own table. Hope some of this helps

            Bob Ashfield Consultants Ltd Proud to be a 2009 Code Project MVP

            P 1 Reply Last reply
            0
            • A Ashfield

              You could use a dataset and fill that, I think you would then get your output parameter straight away - not 100% sure though, I haven't tried it. Alternatively, return 2 recordsets and use a dataadaptor to fill a dataset, you then should get what would have been the output param in its own table. Hope some of this helps

              Bob Ashfield Consultants Ltd Proud to be a 2009 Code Project MVP

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

              Ashfield wrote:

              think you would then get your output parameter straight away

              Unfortunately not - you have to iterate over the lot before you get the output parameter back. This has caused me grief a few times.

              "WPF has many lovers. It's a veritable porn star!" - Josh Smith

              As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.

              My blog | My articles | MoXAML PowerToys | Onyx

              A 1 Reply Last reply
              0
              • P Pete OHanlon

                Ashfield wrote:

                think you would then get your output parameter straight away

                Unfortunately not - you have to iterate over the lot before you get the output parameter back. This has caused me grief a few times.

                "WPF has many lovers. It's a veritable porn star!" - Josh Smith

                As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.

                My blog | My articles | MoXAML PowerToys | Onyx

                A Offline
                A Offline
                Ashfield
                wrote on last edited by
                #7

                Pete O'Hanlon wrote:

                Unfortunately not - you have to iterate over the lot before you get the output parameter back

                Ought to have guessed that really. :-O I never tried it, I generally don't bother with output parameters simply because you can't get them when you really want them, usually first! If I need something like that I often return 2 record sets, the 1st with what would be the output parameter and the 2nd with the real data - probably not ideal, but it works for me :)

                Bob Ashfield Consultants Ltd Proud to be a 2009 Code Project MVP

                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