How can i make a configuration in INI and XML so that i won't hardcode the location of my database and other configurations, and i would just change it from a form within my program? Can anyone help me? thanks..
Usually VS saves connectionstrings in .config file or .settings file which is xml formatted. to do it yourself vs main menu Project->Add new item->.settings file
Add your items in this settings file, you're now can modify your settings without modifying your code.
Avoid using ini files, xml is better.
I'm kind lost there.. Can you teach me how? a little sample code will do, if you don't mind..
Create a new dialog form and use it to manipulate configuration items. On form_load add the items from your program settings:
Private Sub frmConfig_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
' Set the default values into the controls via the program settings
bLoading = True
Me.txtServer.Text = My.Settings.Server
Me.txtDB.Text = My.Settings.Database
bLoading = False
Set flags if they change any of the values and then on the OK_Button_Click test for changes and save them if they exist:
Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
' See if we have anything to save
If Me.bServerChanged Then
My.Settings.Server = Me.txtServer.Text
If Me.bDBChanged Then
My.Settings.Database = Me.txtDB.Text
' If anything changed, save the changes to the setting file
If Me.bServerChanged Or Me.bDBChanged Then
Me.DialogResult = System.Windows.Forms.DialogResult.OK
I want to have a configuration settings editor for my program with mysql.. I want the users to be able to switch from one server to the other using a form. If ill be making an installer for my project where would the config go? can it be read by the application still? or will i specify a path where the application will read its settings..
From VS main menu Project->Add new item select .settings file, once you've added it a designer (tabular) form allows you to add variables add ServerName and assign it a default value.
In coding let's the connection string static except the server name dynamic from the settings file.
public class GrossmontBank
//class variables (global - accessible throughout this class)
//scanner object to be used throughout
private static Scanner input = new Scanner(System.in);