How to alter the connection string in web.config programmatically
ASP.NET
2
Posts
2
Posters
0
Views
1
Watching
-
How to alter the connection string in web.config programmatically? Thanks in Advance.
-
How to alter the connection string in web.config programmatically? Thanks in Advance.
You can programatically open the configuration with using the System.configuration namespace: Configuration myConfig = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); Then you can access the connection strings collection at: myConfig.ConnectionStrings.ConnectionStrings You can modify the collection however you want, and when done call .Save() on the configuration object.
Errors are like Mini Skirts, shorter they get, more revealing they become.