Hi friends
I want to know how to make connection string .NET.
Thank you.
Loading
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.
Satyapriya NayakPosted May 13, 2012, 4:07 AM
Connection string in .NET 2.0 config file
In the appSettings location, add a key named whatever you like to reference your connection string to.
To read the connection string from code, use the ConfigurationSettings class.
string connStr = ConfigurationSettings.AppSettings("myConnectionString");
Now you have the connection string loaded from web.config into your string variable in code.
Connection string in .NET 3.5 (and above) config file
Do not use appsettings in web.config. Instead use the connectionStrings section in web.config.
To read the connection string into your code, use the ConfigurationSettings class.
string connStr = ConfigurationManager.ConnectionStrings["myConnectionString"].ConnectionString;
Thanks
VulpesPosted May 11, 2012, 11:48 AM
http://www.connectionstrings.com/