c#引用web.config中的ConnectionString

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

上一篇:windows linux—unix 跨平台通信集成控制系统----文件搜索


下一篇:使用 Codec Engine 的 API 函数