数据库的链接语句

Data Source/ serversql server名称   (localhost / .\sqlexpress )

Initial catalog/ database数据库名

 示例如下:

1.



    

  

 

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/ uidpwd:登陆方式SSPI

你可能感兴趣的:(数据库的链接语句)