Connection string in web.coonfig file
how can i write connection string in web.config file?
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.
Datta KharadPosted Feb 21, 2012, 4:21 AM
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.
Satyapriya NayakPosted Feb 20, 2012, 10:05 AM
web.config file
Call it in webpage as
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["dbconnection"].ToString());
Thanks