Connection string in web.coonfig file
how can i write connection string in web.config file?
2 Answers
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
Satyapriya NayakRank #47 · 31.5K reputationPosted Feb 20, 2012, 5:05 AM EST
web.config file
Call it in webpage as
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["dbconnection"].ToString());
Thanks
Datta KharadRank #2,135 · 668 reputationPosted Feb 20, 2012, 11:21 PM EST
You can write connection string in web.config file two ways:-
1.
2. You will have to use the "standard" way and also you can encrypt connection string.
Using add key you can not encrypt connection string, it will through error "Unrecognized attribute 'key'.."
add name used in Connectionstring tag of web.config file, it will give name of connection string while add key used in appsettings tag of web.config file.