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. Total rows in DataSet

Total rows in DataSet

Scheduled Pinned Locked Moved Visual Basic
4 Posts 3 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
    penguin5000
    wrote on last edited by
    #1

    Hi, Could anybody tell me what I'm doing wrong with this: Dim objDsExistingXRatesFile As DataSet objDsExistingXRatesFile = New DataSet("StoredRates") objDsExistingXRatesFile.ReadXml("xrates.xml") Dim MaxRows = objDsExistingXRatesFile.Tables("StoredRates").Rows.Count MsgBox(MaxRows.ToString) Its giving me an error on the 'Dim MaxRows' line saying, "NullReferenceException was unhandled" - "Object reference not set to an instance of an object" - advising me that I need to use the New command. It isn't null, because I can put the data into a DataGridView to test it!

    M L 2 Replies Last reply
    0
    • P penguin5000

      Hi, Could anybody tell me what I'm doing wrong with this: Dim objDsExistingXRatesFile As DataSet objDsExistingXRatesFile = New DataSet("StoredRates") objDsExistingXRatesFile.ReadXml("xrates.xml") Dim MaxRows = objDsExistingXRatesFile.Tables("StoredRates").Rows.Count MsgBox(MaxRows.ToString) Its giving me an error on the 'Dim MaxRows' line saying, "NullReferenceException was unhandled" - "Object reference not set to an instance of an object" - advising me that I need to use the New command. It isn't null, because I can put the data into a DataGridView to test it!

      M Offline
      M Offline
      M Hall
      wrote on last edited by
      #2

      Try: Dim MaxRows as integer = objDsExistingXRatesFile.Rows.Count

      1 Reply Last reply
      0
      • P penguin5000

        Hi, Could anybody tell me what I'm doing wrong with this: Dim objDsExistingXRatesFile As DataSet objDsExistingXRatesFile = New DataSet("StoredRates") objDsExistingXRatesFile.ReadXml("xrates.xml") Dim MaxRows = objDsExistingXRatesFile.Tables("StoredRates").Rows.Count MsgBox(MaxRows.ToString) Its giving me an error on the 'Dim MaxRows' line saying, "NullReferenceException was unhandled" - "Object reference not set to an instance of an object" - advising me that I need to use the New command. It isn't null, because I can put the data into a DataGridView to test it!

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Check that the table "StoredRates" actually exists in the objDsExistingXRatesFile dataset. It looks like the name of your dataset is "StoredRates", not the table. Not sure what the table name would be as that may depend on your XML.

        P 1 Reply Last reply
        0
        • L Lost User

          Check that the table "StoredRates" actually exists in the objDsExistingXRatesFile dataset. It looks like the name of your dataset is "StoredRates", not the table. Not sure what the table name would be as that may depend on your XML.

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

          Thanks for your replies. I did a message box for objDsExistingXRatesFile.Tables(0).TableName. I assumed I was assigning the table name when I did the line objDsExistingXRatesFile = New DataSet("StoredRates"). .... obviously not ;)

          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