tmccrank
asked on
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
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
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.
ASKER
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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Dim DA As New DAL_NurseEdMods.DataAccess
That fixed it.
Thanks very much.
J
That fixed it.
Thanks very much.
J