SQL Server连接字符串
时间:2021-07-01 10:21:17
帮助过:14人阅读
windows身份验证1
//string strCon = @"Data Source=.\sqlexpress;Initial Catalog=db1;Integrated Security=True;Pooling=False";
//windows身份验证2
//string strCon = @"server=.\sqlexpress;database=db1;Integrated Security=True;";
//Sql Server身份验证1
//string strCon = @"server=.\sqlexpress;database=db1;uid=sa;pwd=123456";
//Sql Server身份验证2
//string strCon = @"Data Source=.\sqlexpress;Initial Catalog=db1;User ID=sa;Password=123456;Pooling=False";
/*
从配置文件中读连接字符串
在<configuration>标记中加上
<connectionStrings>
<add name="strCon" connectionString="server=.\sqlexpress;database=db1;uid=sa;pwd=123456"/>
</connectionStrings>
*/
string strCon = ConfigurationManager.ConnectionStrings[
"strCon"].ConnectionString;
SQL Server连接字符串
标签:win manage connect 标记 string source initial 字符 config