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 ?
preguntado el 30 de enero de 12 a las 19:01
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.