Need help with editing my vb.net app.config file
This is the app.config file of my vb.net project where my connection string to my database is stored.
Code:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
</configSections>
<connectionStrings>
<add name="MySQL___Conn_Test.My.MySettings.wcConn" connectionString="server=localhost;User Id=root;password=123ssa1;database=wc"
providerName="MySql.Data.MySqlClient" />
</connectionStrings>
<system.diagnostics>
<sources>
<!-- This section defines the logging configuration for My.Application.Log -->
<source name="DefaultSource" switchName="DefaultSwitch">
<listeners>
<add name="FileLog"/>
<!-- Uncomment the below section to write to the Application Event Log -->
<!--<add name="EventLog"/>-->
</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"/>
<!-- Uncomment the below section and replace APPLICATION_NAME with the name of your application to write to the Application Event Log -->
<!--<add name="EventLog" type="System.Diagnostics.EventLogTraceListener" initializeData="APPLICATION_NAME"/> -->
</sharedListeners>
</system.diagnostics>
</configuration>
Look at the part where it says:
Code:
<add name="MySQL___Conn_Test.My.MySettings.wcConn" connectionString="server=localhost;User Id=root;password=123ssa;database=wc"
providerName="MySql.Data.MySqlClient" />
Now this is my problem. I need to change this connection string to:
Code:
"server=192.168.0.24;User Id=root;password=123ssa;database=wc"
The server is no longer local host, but set to the IP of the server.
Here is where my problem comes in. This program will be used on 2 different servers, in other words the IP can't be hardcoded.
Is it possible to edit the app.config file with coding? perhaps load the IP from a .ini file and then connect?
Re: Need help with editing my vb.net app.config file
No, these sections are read-only.
But you can store several connection strings in it and choose the appropriate one.