zoukankan      html  css  js  c++  java
  • 读写WebConfig

    Configuration config = WebConfigurationManager.OpenWebConfiguration("~");
    ConnectionStringsSection cnnSection = (ConnectionStringsSection)config.GetSection("connectionStrings");
     cnnSection.ConnectionStrings.Clear();
     cnnSection.ConnectionStrings.Add(new System.Configuration.ConnectionStringSettings("SQL SERVER", value, "System.Data.SqlClient"));
     config.Save();

    第一个函数的参数是webconfig的位置,如果为null是framwork的根目录下的webconfig,当然默认是没有权限去更改的,这里的“~”意思是当前程序的根目录。当然如果为了保险还可以加入一些权限控制的东西。

    作者:KKcat
        
    个人博客:http://jinzhao.me/
        
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
  • 相关阅读:
    UVa 107 The Cat in the Hat
    UVa 591 Box of Bricks
    UVa 253 Cube painting
    UVa 10161 Ant on a Chessboard
    UVa 401 Palindromes
    UVa 465 Overflow
    我不知道
    消防局的设立
    某CF的D
    保安站岗
  • 原文地址:https://www.cnblogs.com/jinzhao/p/1395996.html
Copyright © 2011-2022 走看看