对于类库里读取解决方案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高手

    本文是从 How to become a proficient Python programmer 这篇文章翻译而来. 这篇文章主要是对我收集的一些文章的摘要.因为已经有很多比我有才华的人写出了大量关 ...

  2. js +1的动画效果

    var fnPlusAnimate = function(str, options){ if (typeof str === 'object') { options = str; str = unde ...

  3. appium +python 一个简单的例子

    appium 安装和python 安装好后. 1.      启动android模拟器--Genymotion-点击Start 2.      启动appium 3.     运行代码. # -*- ...

  4. alpha 发布评论

    1.飞天小女警:礼物挑选小工具. 这一组的项目是个人最为感兴趣的,核心功能的实现比较有实际意义,希望所能挑选的礼物范围尽量足够大,界面期待完善后的效果. 2.nice!:约跑app.这一款面向喜爱运动 ...

  5. Python requests 为pfsense 添加Routes

    # !/usr/bin/python 2 # -*- coding: utf-8 -*- __author__ = "Evilxr" import requests ips = o ...

  6. 简谈ashx

    是一般处理程序, 是asp.net web 组件的一种,ashx是其扩展名. 实现IHttpHandler接口,接收并处理http请求.这个接口有一个IsReusable成员,一个待实现的方法Proc ...

  7. Linux测试环境部署jdk(一)

    安装配置JDK yum install -y lrzsz  安装rz,方便xshell上传下载文件 Jdk: jdk-6u1-linux-i586 Tomcat: apache-tomcat-7.0. ...

  8. 关于javascript中闭包的理解

    闭包就是能够读取其他函数内部变量的函数. 在javascript中,只有函数内部的子函数可以读取局部变量,因此,我理解闭包就是定义在一个函数内部的函数. 例子: var f1 = function() ...

  9. fopen中r+和w+的区别

    r+: Open for reading and writing.  The stream is positioned  at  the beginning of the file. w+:Open ...

  10. esxi 升级

    开启ssh esxcli software vib install -d="/vmfs/volumes/53034105-a8b88330-c096-40f2e993407b/update- ...