0

I get the above error message when I run the below code :

  Using cn As New SqlConnection(ConfigurationManager.ConnectionStrings("Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\SkedDataBasis.mdf;Integrated Security=True").ConnectionString)

Supposedly cn is Nothing. As a newbie and after much research I cannot find my mistake. Any help to make me understand my missing would be much appreciated.

Regards

Gideon
  • 313
  • 1
  • 2
  • 18
  • do you have a setting record named "Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\SkedDataBasis.mdf;Integrated Security=True" in the connection strings part of your app.config \ web.config file ? – Stavm Oct 07 '16 at 07:14
  • 2
    You need to use the **name** of your connection to read it from your app settings - not the entire connection string itself. – Filburt Oct 07 '16 at 07:15
  • Read [this](https://msdn.microsoft.com/en-us/library/ms254494(v=vs.110).aspx?cs-save-lang=1&cs-lang=vb#code-snippet-4) – Han Oct 07 '16 at 07:18
  • Thank you guys. I put the following in my app.config : . I then used SQLConnStr as the name. – Gideon Oct 07 '16 at 11:52
  • Possible duplicate of [What is a NullReferenceException, and how do I fix it?](http://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-and-how-do-i-fix-it) – Chris Dunaway Oct 07 '16 at 13:18

0 Answers0