I am trying to connect to my local database to select a sql database and print the column names but I keep getting this exception:
System.NullReferenceException: 'Object reference not set to an instance of an object.'
System.Configuration.ConnectionStringSettingsCollection.this[string].get returned null.
Can somebody help me?
string constr =
ConfigurationManager.ConnectionStrings[@"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Program Files\Microsoft SQL Server\MSSQL11.SQLEXPRESS\MSSQL\DATA\NORTHWND.MDF;Integrated Security=True;"].ConnectionString;
SqlConnection con = new SqlConnection(constr);