My app is using MySQL. Right now, the IP/Port, username and all that stuff is hard coded in a string.
Public urlMySQLDatabase1 As String = "Server=173.201.88.22;port=3306;Database=DBName;Uid=DBName;Pwd=DBpassword;"
So all the code that needs this string gets it here.
But I was thinking- what if later in the future I need to change this- I could send out an email to the users to open a form I created and they could change the IP. So I created a form, and I can write this IP to an .ini file my app uses to hold some other data.
When the app pulls anything from the .ini file, it calls the loadSettingsFile()
Public Sub loadSettingsFile()
If File.Exists(mySettingsFile) Then
Dim arFileLines() As String = IO.File.ReadAllLines(mySettingsFile)
For Each line As String In arFileLines
With frmLogin
If line.StartsWith("Login ID = ") Then .txtUserID.Text = line.Substring(line.IndexOf("=") + 2)
If line.StartsWith("Password = ") Then .txtUserPassword.Text = line.Substring(line.IndexOf("=") + 2)
End With
With frmServerIP
If line.StartsWith("ServerIP = ") Then .txtServerIP.Text = line.Substring(line.IndexOf("=") + 2)
End With
Next
End If
End Sub
So my question is- how can I write that string above (urlMySQLDatabase1) to use the IP that's written in the .ini file and not always hard coded? I can't seem to wrap my head around this.
TIA