When I was trying to access my connection string from class file using below code
string con = ConfigurationSettings.ConnectionStrings["Conn"].ConnectionString;
I was getting below error.
'System.Configuration.ConfigurationSettings' does not contain a definition for 'ConnectionStrings'
After Google I came you with the solution below,
System.Configuration.ConfigurationSettings.AppSettingsis obsolete. You need to use different class called ConfigurationManager to access information from the configuration file. To Access connection string, your code would look like
string con = System.Configuration.ConfigurationManager.ConnectionStrings["Conn"].ConnectionString
0 comments:
Post a Comment