Set ConnectionString to RunTime

I am starting to program in C #.

I need to edit / install / change the connection string that I saved in my app.config , I use the VS database wizard to create queries.

If you could write code, it would be very nice :)

+4
source share
2 answers

Something like this should start:

 using System.Configuration; var config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); var connectionStrings = config.ConnectionStrings; foreach (var connectionString in connectionStrings.ConnectionStrings) { // change connection details } config.Save(ConfigurationSaveMode.Modified); 
+4
source

Take a look at this article , which shows what exactly you are looking for. This may also be useful. If this is not enough, also check this .

+1
source

All Articles