0

how can i manage connection string of an ADO.net Object model dynamically?

i have connected my application to database using Entity Framework and connection string is automatically added to app.config. how can i get list of available servers and change connections string based on that in the run-time?

4

1 回答 1

0

Just because VS adds the connection string to app.config by default it doesn't mean that is a good idea and if you do keep the connection string there you cannot change it at run time.

One solution is to keep encrypted connection string in your settings and that will allow you to dynamically change it at run time by simply calling:

Settings.Default.Save();

and

Settings.Default.Reload();
于 2013-06-18T17:36:15.137 回答