gpt4 book ai didi

c# - 从 web.config 获取多个连接字符串

转载 作者:可可西里 更新时间:2023-11-01 08:52:23 26 4
gpt4 key购买 nike

如何在C#中通过代码从web.config中获取所有连接字符串的名称?

我试过这个:

System.Configuration.Configuration webConfig = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~");
ConnectionStringsSection x = webConfig.ConnectionStrings;
string here = x.SectionInformation.Name;

最佳答案

    foreach (ConnectionStringSettings c in System.Configuration.ConfigurationManager.ConnectionStrings)
{
//use c.Name
}

关于c# - 从 web.config 获取多个连接字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10384803/

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