ODBC
标准连接
Driver={SQL Server};Server=myServerAddress;Database=myDataBase;
Uid=myUsername;Pwd=myPassword;
受信的连接
Driver={SQL Server};Server=myServerAddress;Database=myDataBase;
Trusted_Connection=Yes;
指定帐号和密码
oConn.Properties(\"Prompt\") = adPromptAlways
Driver={SQL Server};Server=myServerAddress;Database=myDataBase;
OLE DB, OleDbConnection (.NET)
标准连接
Provider=sqloledb;Data Source=myServerAddress;Initial Catalog=myDataBase;
User Id=myUsername;Password=myPassword;
受信的连接
Provider=sqloledb;Data Source=myServerAddress;
Initial Catalog=myDataBase;Integrated Security=SSPI;
使用serverName\\instanceName作为数据源可以指定SQL Server实例。
连接到一个SQL Server的实例
指定服务器实例的表达式和其他SQL Server的连接字符串相同。
Provider=sqloledb;Data Source=myServerName\\theInstanceName;
Initial Catalog=myDataBase;Integrated Security=SSPI;
指定帐户和密码
oConn.Provider = \"sqloledb\"
oConn.Properties(\"Prompt\") = adPromptAlways
Data Source=myServerAddress;Initial Catalog=myDataBase;
使用IP地址的连接
Provider=sqloledb;Data Source=190.190.200.100,1433;
Network Library=DBMSSOCN;Initial Catalog=myDataBase;
User ID=myUsername;Password=myPassword;
SqlConnection (.NET)
标准连接
Data Source=myServerAddress;Initial Catalog=myDataBase;
User Id=myUsername;Password=myPassword;
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;
连接到SQL Server实例
指定服务器实例的表达式和其他SQL Server的连接字符串相同。
Server=myServerName\\theInstanceName;Database=myDataBase;Trusted_Connection=True;
Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;User ID=myDomain\\myUsername;Password=myPassword;
仅能用于CE设备。
带有IP地址的连接
Data Source=190.190.200.100,1433;Network Library=DBMSSOCN;
Initial Catalog=myDataBase;User ID=myUsername;Password=myPassword;
[Page]
指定包的大小
Server=myServerAddress;Database=myDataBase;User ID=myUsername;Password=myPassword;Trusted_Connection=False;Packet Size=4096;
默认的包大小为8192字节。
Data Shape
MS Data Shape
Provider=MSDataShape;Data Provider=SQLOLEDB;Data Source=myServerAddress;
Initial Catalog=myDataBase;User ID=myUsername;Password=myPassword;
e