修改web.config的操作

来源:互联网 发布:如何彻底删除手机数据 编辑:程序博客网 时间:2024/05/01 04:23
需引入System.Configuration.DLL引入名门空间using System.Configuration;using System.Web.Configuration;                        Configuration webconfig = WebConfigurationManager.OpenWebConfiguration("~/");            ConfigurationSectionGroup node_conn = webconfig.SectionGroups["configuration"];            ConnectionStringsSection connSec = (ConnectionStringsSection)node_conn.Sections["connectionStrings"];            connSec.ConnectionStrings.Add(new ConnectionStringSettings("Name","connectionString","providerName"));            webconfig.Save();


原创粉丝点击