2 using System.Data;
3 using System.Configuration;
4 using System.Collections;
5 using System.Web;
6 using System.Web.Security;
7 using System.Web.UI;
8 using System.Web.UI.WebControls;
9 using System.Web.UI.WebControls.WebParts;
10 using System.Web.UI.HtmlControls;
11 using System.Xml;
12 using study.pctoday.net.cn
13 public partial class Default2 : System.Web.UI.Page
14 {
15 protected void Page_Load(object sender, EventArgs e)
16 {
17 Configuration config = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath);
18
19 //操作appSettings
20 AppSettingsSection appseting = (AppSettingsSection)config.GetSection("appSettings");
21 appseting.Settings["web"].Value = "郑少群"; //修改设置
22 appseting.Settings.Add("name", "郑少群"); //增加设置
23
24 //操作connectionStrings
25 ConnectionStringsSection conSection = (ConnectionStringsSection)config.GetSection("connectionStrings");
26 conSection.ConnectionStrings["constr"].ConnectionString = "htttp://study.pctoday.net.cn/App_Data/shaoqun.mdb"; //修改设置
27 conSection.ConnectionStrings["constr"].ProviderName = "System.Data.OleDb";
28 conSection.ConnectionStrings.Add(new ConnectionStringSettings("constr2", "aaaaa", "System.Data.OleDb")); //增加设置
29
30 config.Save();
31 }
32 }
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/12639172/viewspace-623598/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/12639172/viewspace-623598/