Appsettings
can we store connectionstrings in appsettings. How can i access connection string from appsettings.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Kunal NaikPosted Nov 3, 2011, 12:40 AM
Yes we can store connectionstrings in appsettings of web.config file, for that used following steps-
1. Under appsettings of web.config file,
<appSettings>
<add key="EmployeeConnection" value="Data Source=DataSourceName;Initial Catalog=DBName;Persist Security Info=True;User ID=ABC;Password=123"/>
appSettings>
2. After that in your .cs file access this appsetting,
string strcon = System.Configuration.ConfigurationManager.AppSettings["EmployeeConnection"];