Modify ConnectionString in App.Config

  • Thread starter Thread starter MartinThwaites
  • Start date Start date
M

MartinThwaites

Guest
Okay so I've found various different forum posts on this, but none giving a viable solution with a code example in C#... so here goes...

I've created a DataSet using the dataset designer, and this has used the connection string "dataConnectionString" from the app.config.

the problem is that this database is a SqlCe database that will hold userdata. therefore it will be copied from the install directory to a location they specify (allowing them to easily back it up if needed etc.).

This presents a problem in that all the code I've wrote for adding things to the database using the DataSet created tableadaptors etc. is going into the wrong database!

My first thought was to change the dataConnectionString in code, but it appears that ConnectionString settings have to be ApplicationScope and therefore readonly at runtime...

I then thought I would change all the DataSet Designer parts to use a new String Setting i created that can be user-scoped, but that doesn't appear to be possible as it's requiring a ConnectionString...

Can anyone give me a nudge in the right direction? Not asking for a complete how-to, I'm willing to do the research, I'm just getting nowhere right now!

thanks in advance...

Martin

Continue reading...
 
Back
Top