【问题标题】:Changing the connection String in App.config after Installing an Application & application should accept the changes mande in config file安装应用程序和应用程序后更改 App.config 中的连接字符串应接受配置文件中的更改
【发布时间】:2013-11-26 17:18:47
【问题描述】:

问题:

发布并安装 Windows 应用程序后,我想更改 App.config 文件 (3 Tire-Architecture) 中的连接字符串。已安装的应用程序应该能够理解更改后的连接字符串。怎么做。


我有这个 App.config 内容:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
   <connectionStrings>
       <add name="a" connectionString="server=localhost;User Id=root;database=billing"/>
   </connectionStrings>
</configuration>

在 Form1 (say) & 我有 gridview1,它的数据源将从上面的连接字符串中获取。现在我想在不重新发布应用程序的情况下更改它。如何解决这个任务?


【问题讨论】:

    标签: c# app-config setup-deployment


    【解决方案1】:

    您需要创建方法来写入 app.config 并从 app.config 中读取。

    更改您的数据访问层以接受从您的配置文件中读取的连接字符串,然后您就可以开始了。

    互联网上有数百篇关于如何做到这一点的文章。

    This 将帮助您入门。

    【讨论】:

      猜你喜欢
      • 2021-04-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-09
      • 2013-06-13
      相关资源
      最近更新 更多