连接sqlserver的连接字符串
- asp.net 项目配置文件:
Web.config
;
winfrom项目配置文件:App.config
<configuration>
<!--数据库连接-本地-->
<!--<connectionStrings>
<add name="connectionString"
connectionString="server=.;Initial Catalog=ss;Integrated Security=True"
providerName="System.Data.SqlClient"/>
</connectionStrings>-->
<!--数据库连接-sa-->
<connectionStrings>
<add name="ConnectionString"
connectionString="Data Source=10.xx.xx.xx;Initial Catalog=D_xx;User ID=sa;Password=sa;"
providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>
- 读取
using System.Configuration;//引用
private static string constr = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
转自
csdn