string path = VirtualPathUtility.ToAbsolute("~/");
Configuration webConfig = WebConfigurationManager.OpenWebConfiguration(path);
ConnectionStringsSection connSection = webConfig.GetSection("connectionStrings") as ConnectionStringsSection;
connSection.ConnectionStrings["SyfHospitalEntities"].ConnectionString = "aa";
webConfig.Save();
本文介绍了一种方法来修改ASP.NET应用程序中Web.config文件内的连接字符串。通过使用System.Web.Configuration命名空间下的工具,可以轻松地读取和更新配置设置。

被折叠的 条评论
为什么被折叠?



