Results 1 to 2 of 2

Thread: Null Reference Exception was Unhandled

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2009
    Posts
    5

    Null Reference Exception was Unhandled

    I have been trying to retreive information from database A and pass it on to database B

    Dim mr As DataRow = dsProben.Tables("T_Proben").NewRow

    Dim dr1 As DataRow = dsProzessmodule.Tables("T_Prozessmodule").Rows.Find(selectedKey)

    mr("pProzessmodulGUID") = dr1("ProzessmodulGUID")

    though this works in other forms it doesnt seem to work here. I get the error NUll Reference Exception was Unhandled

    could someone help me this.

    thanks

    donny

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

    Re: Null Reference Exception was Unhandled

    When you get a NullReferenceException, the first thing to do EVERY time is to determine exactly which reference is null. You can't solve a problem if you don't know what problem it is. Once you know that you can backtrack to the point that you expected a value to be assigned and that is where the problem lies. In your case I would guess that 'dr1' is Nothing because the table doesn't contain 'selectedKey'. That's just an educated guess though.
    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