一、 <!-- Maticsoft.Accounts权限角色管理模块连接字符串-->
<add key="ConnectionStringAccounts" value="server=127.0.0.1;database=codematic;uid=aa;pwd=111111"/>
<!--其它模块连接字符串,可以不断增加以便同一个项目支持连接多个数据库。如果没有,可以删除该行-->
<add key="ConnectionString2" value="server=127.0.0.1;database=aa;uid=aa;pwd=111111"/>
后台获取代码: string _connectionString = ConfigurationManager.AppSettings["ConnectionString"];
二、<connectionStrings>
<add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-User_webApp-20151205000953;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-User_webApp-20151205000953.mdf"/>
<add name="constr" connectionString="Data Source=(.)\v11.0;AttachDbFilename=|lixi|\db_NetStore.mdf;Integrated Security=True" providerName="System.Data.SqlClient"/>
<add name="constr1" connectionString="Data Source=.;database=lixi;Integrated Security=True"/>
</connectionStrings>
数据库配置
字符串获取:
private static readonly string conString = ConfigurationManager.ConnectionStrings["constr1"].ConnectionString;
<add key="ConnectionStringAccounts" value="server=127.0.0.1;database=codematic;uid=aa;pwd=111111"/>
<!--其它模块连接字符串,可以不断增加以便同一个项目支持连接多个数据库。如果没有,可以删除该行-->
<add key="ConnectionString2" value="server=127.0.0.1;database=aa;uid=aa;pwd=111111"/>
后台获取代码: string _connectionString = ConfigurationManager.AppSettings["ConnectionString"];
二、<connectionStrings>
<add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-User_webApp-20151205000953;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-User_webApp-20151205000953.mdf"/>
<add name="constr" connectionString="Data Source=(.)\v11.0;AttachDbFilename=|lixi|\db_NetStore.mdf;Integrated Security=True" providerName="System.Data.SqlClient"/>
<add name="constr1" connectionString="Data Source=.;database=lixi;Integrated Security=True"/>
</connectionStrings>
数据库配置
字符串获取:
private static readonly string conString = ConfigurationManager.ConnectionStrings["constr1"].ConnectionString;