Tuesday, 15 May 2012

connection string - Is it possible (and how) to add ConnectionString to app.config at runtime in C#? -


I have a console application that receives the connection string as a parameter. I have to set a connection string in app.config with the 'connection' string and the parameters given in the form of SQL Connection String.

I received this with the help of Thx links for the answer:

var config = ConfigurationManager.OpenExeConfiguration (ConfigurationUserLevel.None); Var connectionStringSettings = New connection string settings ("connection string", _arguments ["connectionString"], "system data. SQLLient"); Config.ConnectionStrings.ConnectionStrings.Add (connectionStringSettings); Config.Save (ConfigurationSaveMode.Modified); ConfigurationManager.RefreshSection ("connectionStrings");

Follow this reply and see below .. ..

< P> Yes - have a look at this.

);


No comments:

Post a Comment