本文介绍了如何在app.config文件中写入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Am使用C#Windows应用程序.我使用以下代码在app.cofig文件中写入以更改连接字符串.但是这些更改不是永久的.对于下一次登录,获取的是以前的值而不是新的值. 如何为每次登录获取新的连接字符串?
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); ConfigurationManager.RefreshSection("connectionStrings"); MessageBox.Show( ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString);帮助我..
help me..
推荐答案看看这篇文章:揭开.NET 2.0配置之谜 [ ^ ]-应该有帮助. Have a look at this article: Unravelling the Mysteries of .NET 2.0 Configuration[^] - it should help.
更多推荐
如何在app.config文件中写入
发布评论