Hi friends
I want to know how to make connection string .NET.
Thank you.
Connection string .NET
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
VulpesRank #55 · 29.2K reputationPosted May 11, 2012, 7:48 AM EDT
http://www.connectionstrings.com/
Satyapriya NayakRank #47 · 31.5K reputationPosted May 13, 2012, 12:07 AM EDT
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