SQL server 连接字符串

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/cherish_CX/article/details/52824662


当使用SQL Server身份验证时,必须在连接字符串中指定用户ID和密码:
Data Source=.;Initial Catalog=database  name;User ID=sa;pwd=123;

//如果是连本机数据库date sourse=.就可以了,database name写上自己的数据库名称,sa替换成用户ID,123替换成自己的密码



当windows身份验证或者想要连接不同的数据库,应该指定数据库的名称,:
Data Source=ServerName;Integrated Security=SSPI;Initial Catalog=Northwind

//ServerName是主机名

猜你喜欢

转载自blog.csdn.net/cherish_CX/article/details/52824662