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. Visual Basic
  4. Record count in Reader

Record count in Reader

Scheduled Pinned Locked Moved Visual Basic
4 Posts 2 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.
  • P Offline
    P Offline
    pathak78
    wrote on last edited by
    #1

    Hi, Any one have an idea about counting total records in a reader. Thanks,

    C 2 Replies Last reply
    0
    • P pathak78

      Hi, Any one have an idea about counting total records in a reader. Thanks,

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      pathak78 wrote:

      Any one have an idea about counting total records in a reader.

      Read all the rows out counting as you go. There is no method for giving you a count ahead of time.


      Upcoming Scottish Developers events: * Glasgow: Tell us what you want to see in 2007 My: Website | Blog | Photos

      1 Reply Last reply
      0
      • P pathak78

        Hi, Any one have an idea about counting total records in a reader. Thanks,

        C Offline
        C Offline
        Colin Angus Mackay
        wrote on last edited by
        #3

        Just had another thought. You can send the query SELECT COUNT(*) FROM .... to the datbase followed by the query where you replace COUNT(*) with the columns that you actually want. That way the first result set out of the Data Reader will contain the count. Remember to put both in a transaction so that the count does not change between queries as it is possible another process could sneak in and insert or delete a row in the table you are selecting from.


        Upcoming Scottish Developers events: * Glasgow: Tell us what you want to see in 2007 My: Website | Blog | Photos

        P 1 Reply Last reply
        0
        • C Colin Angus Mackay

          Just had another thought. You can send the query SELECT COUNT(*) FROM .... to the datbase followed by the query where you replace COUNT(*) with the columns that you actually want. That way the first result set out of the Data Reader will contain the count. Remember to put both in a transaction so that the count does not change between queries as it is possible another process could sneak in and insert or delete a row in the table you are selecting from.


          Upcoming Scottish Developers events: * Glasgow: Tell us what you want to see in 2007 My: Website | Blog | Photos

          P Offline
          P Offline
          pathak78
          wrote on last edited by
          #4

          Thanks for your ideas.

          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