c# - Connection String runtime initialization -
how initialize connection string remote file within console application in c# :
i doing appsettings load remote location:
string runtimeappsettingsconfigfile = "c:\somepath\staticappsettings.config"
system.configuration.configuration config = configurationmanager.openexeconfiguration(configurationuserlevel.none); config.appsettings.file = runtimeappsettingsconfigfile; config.save(configurationsavemode.modified); configurationmanager.refreshsection("appsettings");
how accomplish same connection strings config file i.e. load connection string file remotely ?
edit :
what have tried far :
string runtimeconnectionstringconfigfile = "c:\somepath\staticconnectionstrings.config" configuration config = configurationmanager.openexeconfiguration(runtimeconnectionstringconfigfile); config.save(configurationsavemode.modified); configurationmanager.refreshsection("connectionstrings");
connectionstring file sample:
<connectionstrings> <add name="mydb" connectionstring="data source=primarydb;initial catalog=test;persist security info=true;user id=testuser;password=test; asynchronous processing=true" providername="system.data.sqlclient" /> </connectionstrings>
c# configuration runtime
No comments:
Post a Comment