gpt4 book ai didi

.net 3.5 : To read connectionstring from app. 配置?

转载 作者:行者123 更新时间:2023-12-02 01:54:33 25 4
gpt4 key购买 nike

如何使用.net api从app.config文件中读取连接字符串信息?

平台是.net 3.5

     <?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<add connectionString="" providerName="" name=""/>
</connectionStrings>
</configuration>

最佳答案

请参阅Reading Connection Strings in Web.Config and App.Config and Enterprise Library DAAB Settings (在 Wayback Machine 上,原件已被删除)

ConnectionStringSettings connection = ConfigurationManager.ConnectionStrings["MyConnectionString"]
string connectionString = connection.ConnectionString

您可能需要添加对System.Configuration的程序集引用

关于.net 3.5 : To read connectionstring from app. 配置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1831291/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com