Results 1 to 2 of 2

Thread: System.NullReferenceException

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2009
    Posts
    37

    System.NullReferenceException

    hi i am using VB.net 2003 and i am trying to get the number of rows of a dataset from form1 into form2 in order to use it for something else and i am getting the error"System.NullReferenceException occured...Additional information: object reference not set to an instance of an object"...my code is like this:

    in form1:
    Public x as integer= me.dataset.table.rows.count here it gives me the error

    in form2:
    dim frm as new form1
    msgbox(frm.x)

    pls help

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: System.NullReferenceException

    If you're getting a NullReferenceException then you're referring to something that's Nothing. Test each reference on that line and see which it is, then go back and see where you expected a value to be assigned.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width