如何在app.config文件中写入

编程入门 行业动态 更新时间:2024-10-25 20:21:39
本文介绍了如何在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文件中写入

本文发布于:2023-11-08 13:31:15,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1569504.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件   如何在   app   config

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!