非常全面的SQL Server 2005 数据库连接字符串,走过路过,千万莫错过。
一、SQL Native Client ODBC Driver
复制代码代码如下:
Driver={SQL Native Client};Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;
复制代码代码如下:
Driver={SQL Native Client};Server=myServerAddress;Database=myDataBase;Trusted_Connection=yes;
"Integrated Security=SSPI" 与 "Trusted_Connection=yes" 是相同的。
复制代码代码如下:
Driver={SQL Native Client};Server=myServerName/theInstanceName;Database=myDataBase;Trusted_Connection=yes;
复制代码代码如下:
oConn.Properties("Prompt") = adPromptAlways
Driver={SQL Native Client};Server=myServerAddress;Database=myDataBase;
使用MARS (multiple active result sets)
复制代码代码如下:
Driver={SQL Native Client};Server=myServerAddress;Database=myDataBase;Trusted_Connection=yes;MARS_Connection=yes;
"MultipleActiveResultSets=true"与MARS_Connection=yes"是相同的。
复制代码代码如下:
Driver={SQL Native Client};Server=myServerAddress;Database=myDataBase;Trusted_Connection=yes;Encrypt=yes;
复制代码代码如下:
Driver={SQL Native Client};Server=./SQLExpress;AttachDbFilename=c:/asd/qwe/mydbfile.mdf; Database=dbname;Trusted_Connection=Yes;
使用附加本地数据文件夹中的数据库文件的方式连接到本地SQL Server Express实例
复制代码代码如下:
Driver={SQL Native Client};Server=./SQLExpress;AttachDbFilename=|DataDirectory|mydbfile.mdf; Database=dbname;Trusted_Connection=Yes;
复制代码代码如下:
Data Source=myServerAddress;Failover Partner=myMirrorServer;Initial Catalog=myDataBase;Integrated Security=True;
复制代码代码如下:
Provider=SQLNCLI;Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;
复制代码代码如下:
Provider=SQLNCLI;Server=myServerAddress;Database=myDataBase;Trusted_Connection=yes;
"Integrated Security=SSPI"与"Trusted_Connection=yes"相同
复制代码代码如下:
Provider=SQLNCLI;Server=myServerName/theInstanceName;Database=myDataBase;Trusted_Connection=yes;
复制代码代码如下:
oConn.Properties("Prompt") = adPromptAlways
oConn.Open "Provider=SQLNCLI;Server=myServerAddress;DataBase=myDataBase;
使用MARS (multiple active result sets)
复制代码代码如下:
Provider=SQLNCLI;Server=myServerAddress;Database=myDataBase;Trusted_Connection=yes;MarsConn=yes;
"MultipleActiveResultSets=true"和"MARS_Connection=yes"是相同的。
复制代码代码如下:
Provider=SQLNCLI;Server=myServerAddress;Database=myDataBase;Trusted_Connection=yes;Encrypt=yes;
使用附加本地数据库文件的方式连接到本地SQL Server Express实例
复制代码代码如下:
Provider=SQLNCLI;Server=./SQLExpress;AttachDbFilename=c:/asd/qwe/mydbfile.mdf; Database=dbname;Trusted_Connection=Yes;
复制代码代码如下:
Provider=SQLNCLI;Server=./SQLExpress;AttachDbFilename=|DataDirectory|mydbfile.mdf; Database=dbname;Trusted_Connection=Yes;
复制代码代码如下:
Data Source=myServerAddress;Failover Partner=myMirrorServer;Initial Catalog=myDataBase;Integrated Security=True;
标准连接
复制代码代码如下:
Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;
使用serverName/instanceName作为数据源可以指定SQL Server实例。
复制代码代码如下:
Standard Security alternative syntax
Server=myServerAddress;Database=myDataBase;User ID=myUsername;Password=myPassword;Trusted_Connection=False;
受信任的连接
复制代码代码如下:
Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;
Trusted Connection alternative syntax Server=myServerAddress;Database=myDataBase;Trusted_Connection=True;
复制代码代码如下:
Server=myServerName/theInstanceName;Database=myDataBase;Trusted_Connection=True;
复制代码代码如下:
Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;User ID=myDomain/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;Trusted_Connection=True;MultipleActiveResultSets=true;
使用附加本地数据库文件的方式连接到本地SQL Server Express实例
复制代码代码如下:
Server=./SQLExpress;AttachDbFilename=c:/asd/qwe/mydbfile.mdf;Database=dbname;Trusted_Connection=Yes;
复制代码代码如下:
Server=./SQLExpress;AttachDbFilename=|DataDirectory|mydbfile.mdf; Database=dbname;Trusted_Connection=Yes;
复制代码代码如下:
Data Source=./SQLExpress;Integrated Security=true;AttachDbFilename=|DataDirectory|/mydb.mdf;User Instance=true;
数据库镜像
复制代码代码如下:
Data Source=myServerAddress;Failover Partner=myMirrorServer;Initial Catalog=myDataBase;Integrated Security=True;
(责任编辑:IT)Asynchronous processing Server=myServerAddress;Database=myDataBase;Integrated Security=True;Asynchronous Processing=True; |