使用vb.net帮助在app.config中更改连接字符串! [英] change connection string in app.config using vb.net help!

查看:85
本文介绍了使用vb.net帮助在app.config中更改连接字符串!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有包含连接字符串信息的文本文件。我想使用textfile的内容更改app.config中的连接字符串。在VB.net请!谢谢!



i have text file having connection string info. I want to change connection string in app.config using the content of textfile. in VB.net please! thanks!

<connectionStrings>
        <add name="Inventory_System.My.MySettings.AWDConnectionString"
            connectionString="Data Source=instance name;Initial Catalog=db name;User Id=username; Password=password"
            providerName="System.Data.SqlClient" />
    </connectionStrings>

推荐答案

这不是app.config的工作原理。运行时没有app.config文件,它不是产品的一部分。您可以部署的文件是重命名为youApplicationName.exe.config的文件。并且在启动应用程序后,假定此文件内容是不可变的。即使更改文件内容本身,也不会修改应用程序的行为。如果需要重新连接或使用不同的连接字符串获取另一个连接,则需要使用其他一些机制来实现此目的。例如,您可以选择固定的连接字符串或其他内容;这取决于你的架构。



-SA
This is not how "app.config" works. There is no "app.config" file during runtime, it is not a part of the product. The file you can deploy is the same file renamed as "youApplicationName.exe.config". And this file content is assumed to be immutable after the application is started. Even if change the file content itself, it won't modify the behavior of your application. If you need to reconnect or get another connection with different connection string, you need to use some other mechanism for this purpose. For example, you could have a choice in a fixed set connection strings, or something; it depends on your architecture.

—SA


这篇关于使用vb.net帮助在app.config中更改连接字符串!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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