using ConfigurationManager won't do any good cause u get ConfigurationErrorsExcepti
on if u try to change setting saying: "[System.Configuration.Con
figuration
ErrorsExce
ption] = {"The configuration is read only."}"
u would have to handle the conection string yourself.
u can still use the app.config to store/modify connection string properties, however, u will have to create a custom configuration manager which will use other methods to access the app.config and update the connection string.
since app.config is xml based file u can parse it as one, using XElement,XmlDocument etc.
or better yet u can load the app.config explicitly using ConfigurationManager.OpenM
appedExeCo
nfiguratio
n() and then add/modify connection string properties:
Configuration exConfiguration = ConfigurationManager.OpenM
appedExeCo
nfiguratio
n(new ExeConfigurationFileMap
{
ExeConfigFilename = @"c:\temp\app.config"
}, ConfigurationUserLevel.Non
e);
exConfiguration.Connection
Strings.Co
nnectionSt
rings[0] = new ConnectionStringSettings("
","NECTION_STRING>","VIDER>");