日期:2014-05-16  浏览次数:20413 次

C# 连接SQL数据库

Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;
Data Source
=190.190.200.100,1433;Network Library=DBMSSOCN;Initial Catalog=myDataBase;User ID=myUsername;Password=myPassword;
Server
=myServerAddress;Database=myDataBase;User ID=myUsername;Password=myPassword;Trusted_Connection=False;
Server
=myServerAddress;Database=myDataBase;Trusted_Connection=True;
Server
=myServerName\theInstanceName;Database=myDataBase;Trusted_Connection=True;
Data Source
=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;

1:Integrated Security参数
??? 当设置Integrated Security为 True 的时候,连接语句前面的 UserID, PW 是不起作用的,即采用windows身份验证模式。
??? 只有设置为 False 或省略该项的时候,才按照 UserID, PW 来连接。
??? Integrated Security 还可以设置为:sspi ,相当于 True,建议用这个代替 True。
??? Data Source
=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;
??? Data Source
=myServerAddress;Initial Catalog=myDataBase;Integrated Security=true;
??? Data Source
=myServerAddress;Initial Catalog=