需引入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();
修改web.config的操作
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.