C# - Get database connection string from Web.config file
To get the database connection string from IIS Web.config file using C# code, include System.Configuration directive and then create a string variable to assign the connection string like this:
using System.Configuration; string connStr = ConfigurationManager. ConnectionStrings["connectionString_Name"].ConnectionString;If “ConfigurationManager” is not recognized you will need to add reference to: "System.Configuration".See: C# - How to add reference to project
PROGRAMMING HELP | C# | WEB.CONFIG
2017/10/05 02:45
1