问题
I´m a beginner in C# programming.
I need to edit/set/change my connection string that I stored in my app.config
, I'm using VS database wizard to create the queries.
If you could write the code it will be very nice :)
回答1:
Something like this should get you started:
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);
来源:https://stackoverflow.com/questions/14349734/set-connectionstring-at-runtime