Click here to Skip to main content
15,667,736 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Am using C# windows application. i used following code to write in app.cofig file to change connection string.but those chnages are not permanent. For next login am getting previous values instead of new values.

how to get new connection string for every login?

Configuration config = ConfigurationManager.OpenExeConfiguration( ConfigurationUserLevel.None );
           config.ConnectionStrings.ConnectionStrings.Add( new ConnectionStringSettings("MyConnectionString", String.Format("DataSource={0};InitialCatalog={1}; IntegratedSecurity={2}","testing", "testing2", "Testing6")));
           config.Save( ConfigurationSaveMode.Modified, true);
           MessageBox.Show( ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString);

help me..
Updated 28-Mar-10 2:39am

1 solution

Have a look at this article: Unravelling the Mysteries of .NET 2.0 Configuration[^] - it should help.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900