如何在app.config文件中写入 [英] How to write in app.config file

查看:129
本文介绍了如何在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..

推荐答案

看看这篇文章: ^ ]-应该有帮助.
Have a look at this article: Unravelling the Mysteries of .NET 2.0 Configuration[^] - it should help.


这篇关于如何在app.config文件中写入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆