首页 > Windows开发 > 详细

c#引用web.config中的ConnectionString

时间:2015-01-01 22:29:27      阅读:1222      评论:0      收藏:0      [点我收藏+]

c#引用web.config中的ConnectionString

<connectionStrings>
  <add name="JKXTConnectionString" connectionString="Data Source=CHF;Initial Catalog=JKXT;User ID=sa" providerName="System.Data.SqlClient" />
  <add name="JGXTConnectionString" connectionString="Data Source=CHF;Initial Catalog=JGXT;User ID=sa" providerName="System.Data.SqlClient" />
 </connectionStrings>

 

<connectionStrings>
    <add name="DB_EMSConnectionString" connectionString="Data Source=85DDBBBFA5A34F9;Initial Catalog=DB_EMS;Integrated Security=True" providerName="System.Data.SqlClient" />

</connectionStrings>


获取的办法是:
ConfigurationManager.ConnectionStrings["JGXTConnectionString"].ConnectionString;

或者这么写web.config
 <appSettings>
  <add key="connectionstring" value="Data Source=CHF;Initial Catalog=JGXT;User ID=sa"/>
 </appSettings>

 

<appSettings>

<add key="DbHelperProvider" value="System.Data.SqlClient"/>

<add key="DbHelperConnectionString" value="Data Source=85DDBBBFA5A34F9;Initial Catalog=DB_EMS;Integrated Security=True"/>

</appSettings>


获取办法是:
ConfigurationSettings.AppSettings["JGXTConnectionString"];

引用using System.Configuration;

c#引用web.config中的ConnectionString

原文:http://www.cnblogs.com/furenjian/p/4197902.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!