Skip to main content

Error when adding new Data Source

Published 1 min readMarkdown
Error when adding new Data Source

I’ve experienced the strangest error when I try to add a new datasource via the Data Sources window in Visual Studio. The Data Source Configuration Wizards pops up, I select I want to bind to an object, click on next and get the following error:

![DataSourceError](http://www.mythicalmanmoth.com/wp-content/uploads/2009/10/datasourceerror-thumb.gif "DataSourceError")
(Click to view larger image)

Yes, the dreaded Object reference not set to an instance of an object error.

After a considerable amount of time spent checking references, adding references, re-building and a lot of profanity, I finally discovered that VS expects a class in the root of your project for the Data Source Configuration Wizard to bind to an object. I moved all my forms and classes to folders within my project, thus I had no classes in the root of my project.

After creating an empty Class1.vb in the root of my project the error went away.

Go figure!!

About the author

  • Pieter van der Westhuizen, a professional freelance web & mobile developer and founder of Coalition Software.

More from this blog

Error when adding new Data Source