-3

System.NullReferenceException was unhandled by user code

getting exception at this line

SqlConnection conn = new SqlConnection(
                       ConfigurationManager.
                       ConnectionStrings["SqlDataSourceRegistration"].
                       ConnectionString);
rene
  • 37,946
  • 78
  • 99
  • 132
user3555689
  • 33
  • 1
  • 6

1 Answers1

3

Your connection string SqlDataSourceRegistration does not exist.

Check your app.config or web.config and check whether you spelled the connection string right, or whether you added it at all. Read MSDN: Connection Strings and Configuration Files how to do this.

EDIT:

The connection string is called RegistrationConnectionString.

Use this:

SqlConnection conn = new SqlConnection(
                       ConfigurationManager.
                       ConnectionStrings["RegistrationConnectionString"].
                       ConnectionString);
Patrick Hofman
  • 143,714
  • 19
  • 222
  • 294