• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 238
  • Last Modified:

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

It stops on the first line, but I'm stuck on what it means!

Thanks for any help!
  • 3
  • 2
1 Solution
Andrew BeersCommented:

Requires that you have defined DA

If you have not defined DA then this will not work because DA is being treated as an object refrence it is declaring that it is not set to any known instance of an object.  

Let me know if this helps.

tmccrankAuthor Commented:
Thanks Aqua,

I defined DA at the form level (if that's the right term) since I wanted it to be in scope for all the methods in the Class.

That is, just below the Web Form Designer Generated Code block, I did this:

Dim DA As DAL NurseEdMods.DataAccess

Is that what you meant by defining DA?

Andrew BeersCommented:
You might want to double check your syntax there.  VBScript gets very picky on where you use as and where you use set.  I think your best option here is to double check your objects with MSDN and check in their sample code.  Without weeding through your entire code I'm not very likely to decipher your exact problem.  But with that line throwing an error you have one of two problems:

DA is undefined


You need to instance alDD before assigning it to the return property of DA.PopulateDropDown()

I'm leaving work shortly and will be unavailable to post for a few hours however if you'd like to post your code for this I'll dig through it to see what I can find.  ((This isn't one of my strongest langauges but I can muddle through it))

tmccrankAuthor Commented:
...Sorry, DAL NurseEdMods.DataAccess should read DAL_NurseEdMods.DataAccess.
tmccrankAuthor Commented:
Thanks... I just realized that there's a seperate VB.NET forum which I should have posted to.  I'll try it there and see what happens.
Posting the rest of my code probably wouldn't help much (it seems to me, which isn't saying much) since the error is popping up right at the first line of code.  I set a breakpoint on it which should at least fire me to the PopulateDropDown() method in my Data Access Layer, but that's not happening.  Hm.  Anyway, I'll try it over in VB.NET.  Hopefully I can award you the points for the time you took to answer.
Thanks again,

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now