Object reference not set to an instance of an Object...

If I had a nickel for everytime I got this error.... this one has had this noob guessing for a while though.

Here's my code in the Page_Load sub:

        ' the PopulateDropDown() method returns an ArrrayList from my DAL.
        Dim alDD As ArrayList = DA.PopulateDropDown()

        'populate Modules drop down list
        ddlModules.DataSource = alDD
        ddlModules.DataBind()

The exception is thrown on the first line, but I'm obviously stuck on why.  The DA was dimmed at the form level (just below the Web Form Designer Generated Code block) so it would be in scope for all methods in that Class:

Dim DA As DAL_NurseEdMods.DataAccess

Thanks for any help!
J
tmccrankAsked:
Who is Participating?
 
Carl TawnConnect With a Mentor Systems and Integration DeveloperCommented:
No, DA should be a valid object at this point. PopulateDropDown() is a method of whatever class DA is. So you need to look at the declaration of DA.

Chances are you code says something like:

    Dim DA As SomeClass

Rather than:

   Dim DA As New SomeClass()

Or:

   Dim DA As SomeClass = New SomeClass()
0
 
Carl TawnSystems and Integration DeveloperCommented:
Time to dust off the debugger. Put a breakpoint on the line in question and double-check that DA is a valid object. If it is, then it may be a problem with what "PopulateDropDown()" is returning.
0
 
tmccrankAuthor Commented:
Thanks Carl,
I tried the breakpoint, but the exception is thrown even before the debugger steps in to the PopulateDropDown() function, which tells me that it can't be that method.  Is this right?
Anyway, during debugging DA is showing up as "Nothing".  But won't it be "Nothing" until the function returns an ArrayList?  Like I said earlier, it's not even going there.
J
0
 
tmccrankAuthor Commented:
Dim DA As New DAL_NurseEdMods.DataAccess

That fixed it.
Thanks very much.
J
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.