I’ve never used the “appSettings” before. How do you configure this in C# to use with a SqlConnection, this is what I use for the “ConnectionStrings”
SqlConnection con = new SqlConnection();
con.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
And this is what I have for the “appSettings”
SqlConnection con = new SqlConnection();
con = ConfigurationManager.AppSettings("ConnectionString");
but it is not working.
ConfigurationManager.AppSettingsis actually a property, so you need to use square brackets.Overall, here’s what you need to do:
The problem is that you tried to set con to a string, which is not correct.
You have to either pass it to the constructor or set con.ConnectionString property.