This is the app.config file of my vb.net project where my connection string to my database is stored.
Look at the part where it says: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>Now this is my problem. I need to change this connection string to:Code:<add name="MySQL___Conn_Test.My.MySettings.wcConn" connectionString="server=localhost;User Id=root;password=123ssa;database=wc" providerName="MySql.Data.MySqlClient" />
The server is no longer local host, but set to the IP of the server.Code:"server=192.168.0.24;User Id=root;password=123ssa;database=wc"
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?


Reply With Quote
