Appsettings
can we store connectionstrings in appsettings. How can i access connection string from appsettings.
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Kunal Naik163 reputationPosted Nov 2, 2011, 8:40 PM EDT
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"];