Data Source/ server:sql server名称 (localhost / .\sqlexpress )
Initial catalog/ database:数据库名
示例如下:
1.
<connectionStrings>
<add name="SqlServices" connectionString="Data Source=localhost;Integrated Security=SSPI;Initial Catalog=db_Blog;" providerName="System.Data.SqlClient"/>
</connectionStrings>
string settings = Convert.ToString(ConfigurationManager.ConnectionStrings["SqlServices"]);
SqlConnection myconn = new SqlConnection(settings);
myconn.Open();
2.
conn.ConnectionString = "Data Source=.\\SQLExpress;Integrated Security=true; AttachDbFilename=|DataDirectory|\\Database.mdf;User Instance=true;";
Integrated Security/ uid,pwd:登陆方式(SSPI)