[C#常用代码]类库中读取解决方案web.Config字符串
对于类库里读取解决方案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="DATA SOURCE=FT8000;PASSWORD=fterp201501!!;PERSIST SECURITY INFO=True;USER ID=ft800"" 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字符串的更多相关文章
- .NET Core类库中读取配置文件
最近在开发基于.NET Core的NuGet包,遇到一个问题:.NET Core中已经没有ConfigurationManager类,在类库中无法像.NET Framework那样读取App.conf ...
- asp.net 2.0中新增的web.config的默认namespace功能 (转)
看上去这个题目比较长,但实际上,我在看资料时发现,这就是说,在asp.net 2.0中,只需要在web.config里定义你要用的那些namespace,则在aspx页面中就不需要再象1.1那样,用 ...
- .NET Core在类库中读取配置文件appsettings.json
在.NET Framework框架时代我们的应用配置内容一般都是写在Web.config或者App.config文件中,读取这两个配置文件只需要引用System.Configuration程序集,分别 ...
- Asp.Net中的获取Web.config中设置的参数!(前后台的代码示例)
一.Web.config中设置代码 <appSettings> <add key="deleted" value="1" ...
- .NET Core 类库中读取appsettings.json
{ "Logging": { "IncludeScopes": false, "LogLevel": { "Default&quo ...
- ASP.NET程序中动态修改web.config中的设置项目(后台CS代码)
using System;using System.Collections;using System.ComponentModel;using System.Data;using System.Dra ...
- EF开发中EntityFramework在web.config中的配置问题
异常: 未找到具有固定名称“System.Data.SqlClient”的 ADO.NET 提供程序的实体框架提供程序.请确保在应用程序配置文件的“entityFramework”节中注册了该提供程序 ...
- IIS如何避免子web应用程序中继承根目录web.config配置
1.一种方式,需要改动根目录的web.config(不是很推荐) <?xml version="1.0"?> <configuration> <loc ...
- C#常用代码(更新中)
文件(夹)的相关操作 新建文件夹 If(!Directory.Exist(路径)) Directory.CreateDirectory(路径); 删除文件夹 Directory.Delete(路径,t ...
随机推荐
- The long way
转眼毕业一年多了,经历的好复杂,从PHP转到了C++,回到了老本行. 虽然PHPDE各种框架已经很熟了,但是仍然感觉这不是我想要的. 回到C++,才发现这才是自己的方向,心也跟着静了下来. 但是莫名的 ...
- linux下MySQL安装及设置
转自:http://www.entage.net/1/viewspace-25420 1. 关于本文 本文将以MySQL 5.0.51为例,以CentOS 5为平台,讲述MySQL数据库的安装和 ...
- SqlServer 触发器
--创建insert类型的触发器create trigger tgr_product_insert --创建触发器 on product --所针对的表 for insert --触发 ...
- React的虚拟DOM
ReactJs的一大特点就是引进了虚拟dom(Virtual DOM)的概念.为什么我们需要Virtual DOM,Virtual DOM给我们带来了什么优势. 首先我们要了解一下浏览器的工作流. 当 ...
- c语言数据结构之 插入排序
算法:从第二个元素开始,与前一个元素进行比较,如果小于前一个元素,两者交换位置,一直循环到不再小为止 编译器:VS2013 代码 #include "stdafx.h"#inclu ...
- template 不能分别在.h和.cpp中定义模板
先上代码: #ifndef SEQLIST_H #define SEQLIST_H #include <iostream> ; template <typename type> ...
- 转:StrictMode使用
最新的Android平台中(Android 2.3起),新增加了一个新的类,叫StrictMode(android.os.StrictMode).这个类可以用来帮助开发者改进他们编写的应用,并且提供了 ...
- Django后台post请求中的csrf token
使用Requests库操作自己的Django站点,post登陆admin页面返回403,serverlog显示csrf token not set. csrf token是get登陆页面时服务器放在c ...
- 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 ...
- Codeforces Round #341 Div.2 C. Wet Shark and Flowers
题意: 不概括了..太长了.. 额第一次做这种问题 算是概率dp吗? 保存前缀项中第一个和最后一个的概率 然后每添加新的一项 就解除前缀和第一项和最后一项的关系 并添加新的一项和保存的两项的关系 这里 ...