Hi All
I have a .net application
I need some help updating app.config file - connectionstring
it has 3 connectionstring entries of which i like to update 1
I have found code but this does not update anything.
please point me in the right direction
Below the app.config:
="1.0"
<configuration>
<configSections>
</configSections>
<connectionStrings>
<add name="FlexiSchool.My.MySettings.AbacusSchool_beConnectionString"
connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\Hss\data\Azura\Flexischool\DATA_be.mdb"
providerName="System.Data.OleDb" />
<add name="FlexiSchool.My.MySettings.SI_DBConnectionString" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\Hss\data\Azura\Flexischool\SI_DB.accdb"
providerName="System.Data.OleDb" />
<add name="FlexiSchool.My.MySettings.AdminSettingsConnectionString"
connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\Hss\data\Azura\Flexischool\AdminSettings.mdb;Persist Security Info=True;Jet OLEDB:Database Password=ilze10koen"
providerName="System.Data.OleDb" />
</connectionStrings>
<system.diagnostics>
<sources>
<source name="DefaultSource" switchName="DefaultSwitch">
<listeners>
<add name="FileLog"/>
</listeners>
</source>
</sources>
<switches>
<add name="DefaultSwitch" value="Information"/>
</switches>
<sharedListeners>
<add name="FileLog" type="Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" initializeData="FileLogWriter"/>
</sharedListeners>
</system.diagnostics>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup>
</configuration>
What I have tried:
below the code snippet:
Dim config As System.Configuration.Configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None)
Dim mySection As ConnectionStringsSection = DirectCast(config.GetSection("FlexiSchool.My.MySettings.AbacusSchool_beConnectionString"), ConnectionStringsSection)
config.ConnectionStrings.ConnectionStrings("FlexiSchool.My.MySettings.AbacusSchool_beConnectionString").ConnectionString = DataPath.Text & "DATA_BE.mdb"
Try
config.Save(ConfigurationSaveMode.Full)
Catch ex As Exception
ex.Message.ToString()
End Try
'ConfigurationManager.RefreshSection("connectionStrings")
Try
ConfigurationManager.RefreshSection("connectionStrings")
Catch ex As Exception
ex.Message.ToString()
End Try