How To Change The Connection String saved in My.Settings in VB 2010

27,530

Here's how to edit the setting via code:

My.Settings.Item("ConnectionString") = "some connection string"

However, an easier solution would be to just use the app.config file. When the wizard creates your DataSets it should be adding the connection strings to app.config, which will get copied to your project's output directory as <assemblyName>.config. Then your installer could determine the proper connection string and edit the .config file automatically. Also, your users could edit the config file manually.

Share:
27,530
Admin
Author by

Admin

Updated on July 09, 2022

Comments

  • Admin
    Admin almost 2 years

    I am writting an application and I used Wizard to create DataSets which auto-created their own xml code. This code uses the saved in My.Settings Connection String. Being a setting with an unchangable 'Application' scope i cannot change its value at runtime. The problem is that when I install the Application to my customer the Connection String will have to change (maybe more than once). So is there a way to change the Connection String used by these objects at runtime ?