sqlserver2008连接字符串

时间:2022-10-11 04:42:49

标准连接:


string str="Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=myPassword;";


信任连接:


string str="Server=myServerAddress;Database=myDataBase;Trusted_Connection=True;";

连接服务器某个实例


string str="Server=myServerName\myInstanceName;Database=myDataBase;

User Id=myUsername;Password=myPassword;";


 附加一个文件到sqlsever express实例


string str="Server=.\SQLExpress;AttachDbFilename=C:\MyFolder\MyDataFile.mdf;

Database=dbname;Trusted_Connection=Yes;";


具体的参考:

http://www.connectionstrings.com