You have already written Connection String in Web.Config file of your Web Application, Now you want to retrieve its value in code, So that you can connect to your Database. In this article I will show you how can you do this.
- Connection String From AppSettings
If you have stored Connection String value in AppSettings then use this following code to get its value from Web.Config file in your code.
string connectionString = System.Configuration.ConfigurationManager.AppSettings["conn"].ToString(); - Connection String From ConnectionStrings
If you have stored Connection String value in ConnectionStrings tag in Web.Config then use this following code to get its value from Web.Config file in your code.string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["conn"].ToString();
Incoming search terms:
- facebook punjabi configuration (1)
- recuperation connectionstring web config (1)