对于类库里读取解决方案web.config文件里字符串的方法
一.读取键值对的方法;
1.添加引用
using System.Configuration;
2.web.Config配置节
<appSettings>
    <!--现场维护从当前月向前跨几个月-->
    <add key="CrossMonthNum" value="2"/>
  </appSettings>
3.代码
 public static string FileUploadPath
{
    get
    {
        //return System.Web.Configuration.WebConfigurationManager.AppSettings["fileStorePath"];
        return ConfigurationManager.AppSettings["fileStorePath"];
    }
}

二.读取数据库连接串
1.添加引用
using System.Configuration;
2.web.Config配置节
 
  <connectionStrings>
    <!--Oracel链接-->
    <add name="ERP_FT800" connectionString="metadata=res://*/ERP.csdl|res://*/ERP.ssdl|res://*/ERP.msl;provider=Oracle.ManagedDataAccess.Client;provider connection string=&quot;DATA SOURCE=FT8000;PASSWORD=fterp201501!!;PERSIST SECURITY INFO=True;USER ID=ft800&quot;" providerName="System.Data.EntityClient"/>
    <add name="FTCE_ACCS_SystemCon" connectionString="Data Source=192.168.10.611;Initial Catalog=FTCE_ACCS;Persist Security Info=True;User ID=sa;Password=P@ssw0rd" providerName="System.Data.SqlClient"/>
    
    <add name="FTCEORACLE" connectionString="Data Source=ftcesys;Persist Security Info=True;User ID=lqmuser;Password=qmuser" providerName="System.Data.OracleClient"/>
    <!--erp数据库接口-->
    <add name="ERPORACLE" connectionString="Data Source=fterp;Persist Security Info=True;User ID=ft800;Password=fterp201501!!" providerName="System.Data.OracleClient"/>
    <add name="ERP_READONLY" connectionString="Data Source=fterp;Persist Security Info=True;User ID=ft800;Password=fterp201501!!" providerName="System.Data.OracleClient"/>
    <!--临时使用  模拟特采系统或其他SQLServer数据库接口-->               
    <add name="FTCE_Interface_SystemCon" connectionString="Data Source=192.168.130.111;Initial Catalog=FTCE_Interface;Persist Security Info=True;User ID=sa;Password=P@ssw0rd" providerName="System.Data.SqlClient"/>
  </connectionStrings>
3.读取字符串代码
ConfigurationManager.ConnectionStrings["FTCE_CW_SystemCon"].ConnectionString

[C#常用代码]类库中读取解决方案web.Config字符串的更多相关文章

  1. .NET Core类库中读取配置文件

    最近在开发基于.NET Core的NuGet包,遇到一个问题:.NET Core中已经没有ConfigurationManager类,在类库中无法像.NET Framework那样读取App.conf ...

  2. asp.net 2.0中新增的web.config的默认namespace功能 (转)

    看上去这个题目比较长,但实际上,我在看资料时发现,这就是说,在asp.net 2.0中,只需要在web.config里定义你要用的那些namespace,则在aspx页面中就不需要再象1.1那样,用 ...

  3. .NET Core在类库中读取配置文件appsettings.json

    在.NET Framework框架时代我们的应用配置内容一般都是写在Web.config或者App.config文件中,读取这两个配置文件只需要引用System.Configuration程序集,分别 ...

  4. Asp.Net中的获取Web.config中设置的参数!(前后台的代码示例)

    一.Web.config中设置代码     <appSettings>         <add key="deleted" value="1" ...

  5. .NET Core 类库中读取appsettings.json

    { "Logging": { "IncludeScopes": false, "LogLevel": { "Default&quo ...

  6. ASP.NET程序中动态修改web.config中的设置项目(后台CS代码)

    using System;using System.Collections;using System.ComponentModel;using System.Data;using System.Dra ...

  7. EF开发中EntityFramework在web.config中的配置问题

    异常: 未找到具有固定名称“System.Data.SqlClient”的 ADO.NET 提供程序的实体框架提供程序.请确保在应用程序配置文件的“entityFramework”节中注册了该提供程序 ...

  8. IIS如何避免子web应用程序中继承根目录web.config配置

    1.一种方式,需要改动根目录的web.config(不是很推荐) <?xml version="1.0"?> <configuration> <loc ...

  9. C#常用代码(更新中)

    文件(夹)的相关操作 新建文件夹 If(!Directory.Exist(路径)) Directory.CreateDirectory(路径); 删除文件夹 Directory.Delete(路径,t ...

随机推荐

  1. Python列表

    列表不同于字符串和元组:列表是可变的--可以改变列表的内容 1.列表函数 1.list(x)函数(其实是一种类型,而不是一个真正意义上的函数) 转化为列表,其中x可以是其他序列 可以用''.join( ...

  2. leetcode 186. Reverse Words in a String II 旋转字符数组 ---------- java

    Given an input string, reverse the string word by word. A word is defined as a sequence of non-space ...

  3. Ecstore会员密码加密方式破解

    <?php //以下是加密方式,亲测有效 $string_md5 = md5(md5("密码")."用户名"."注册时间");//三个 ...

  4. 2016HUAS_ACM暑假集训3G - 还是畅通工程

    最小生成树,题目简单.套的Prim模板,其他的题目比较有意义. Sample Input 3                             //村庄个数1 2 1               ...

  5. wiseinstall 制做安装包小记

    好久没写博客了..昨天未来的自己给自己托了个梦,说以后你肯定会忘了你今天白天是怎么制做安装包的,所以又来记录了..希望以后可以保持这个好习惯. 程序安装完后,可执行程序是 Wise32.exe 第一步 ...

  6. 【ZOJ1003】Crashing Balloon(DFS)

    Crashing Balloon Time Limit: 2 Seconds      Memory Limit: 65536 KB On every June 1st, the Children's ...

  7. HTTP 协议中GET和POST到底有哪些区别

    HTTP 定义了与服务器交互的不同方法,最常用的有4种,Get.Post.Put.Delete,如果我换一下顺序就好记了,Put(增),Delete(删),Post(改),Get(查),即增删改查,下 ...

  8. Linux下搭建VPN服务器(CentOS、pptp)转

    先说我搭建过程中出现的问题吧: 按照 教程搭建好之后出现了619错误,查看日志:/var/log/messages: Nov 20 09:46:20 localhost pptpd[7498]: GR ...

  9. 学习地址(oraclemysqllinux)

    1.安装配置 http://blog.chinaunix.net/uid-27126319-id-3466193.htmlhttp://www.cnblogs.com/gaojun/archive/2 ...

  10. win 安装mysql

    windows上安装sql最容易出现 1067错误,网上查了很多,大部分都是误导.现在将验证过的步骤总结如下: 1.下载mysql,我用的是mysql-5.6.24-win32 下载后解压,进入到bi ...