SQL SERVER
Standard Security
Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;
 
 
Standard Security alternative syntax
This connection string produces the same result as the previous one. The reason to include it is to point out that some connection string keywords have many equivalents.
Server=myServerAddress;Database=myDataBase;User ID=myUsername;免费java编辑器Password=myPassword;Trusted_Connection=False;
 
 
Trusted Connection
带滑块座轴承Data Source=myServerAddress;Initial Catalog=myDataBase;孙侨潞抢救时的照片Integrated Security=SSPI;
 
 
Trusted Connection alternative syntax
This connection string produce the same result as the previous one. The reason to include it is to point out that some connection string keywords have many equivalents.
Server=myServerAddress;Database=myDataBase;Trusted_Connection=True;
Use serverName\instanceName as Data Source to use a specific SQL Server instance. Please note that the multiple SQL Server instances feature is available only from SQL Server version 2000 and not in any previous versions.
 
Connecting to an SQL Server instance
The syntax of specifying the server instance in the value of the server key is the same for all connection strings for SQL Server.
Server=myServerName\theInstanceName;Database=myDataBase;Trusted_Connection=True;
 
 
Trusted Connection from a CE device
Often a Windows CE device is not authenticated and logged in to a domain. To use SSPI or trusted connection / authentication from a CE device, use this connection string.
Data Source=myServerAddress;中序线索二叉树的遍历算法Initial Catalog=myDataBase;excel中的基本函数有哪些Integrated Security=SSPI;User ID=myDomain\myUsername;Password=myPassword;
Note that this will only work on a CE device.
Read more about connecting to SQL Server from CE devices here
 
Connect via an IP address
Data Source=190.190.200.100,1433;Network Library=DBMSSOCN;Initial Catalog=myDataBase;User ID=myUsername;Password=myPassword;
 
Specifying packet size
Server=myServerAddress;Database=myDataBase;User ID=myUsername;Password=myPassword;Trusted_Connection=False;Packet Size=4096;
By default, the Microsoft .NET Framework Data Provider for SQL Server sets the network
packet size to 8192 bytes. This might however not be optimal, try to set this value to 4096 instead.
The default value of 8192 might cause errors as well ("Failed to reserve contiguous memory"), check this out
 
Microsoft OLE DB Provider for SQL Server
Type:    OLE DB Provider
Usage:  Provider=sqloledb
Manufacturer:  Microsoft
More info about this provider »
Customize string
example values »
Standard Security
Provider=mysql面试题大全sqloledb;Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;
 
 
Trusted connection
Provider=sqloledb;Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;
Use serverName\instanceName as Data Source to use a specific SQL Server instance. Please note that the multiple SQL Server instances feature is available only from SQL Server version 2000 and not in any previous versions.
 
Connecting to an SQL Server instance
The syntax of specifying the server instance in the value of the server key is the same for all connection strings for SQL Server.
Provider=sqloledb;Data Source=myServerName\theInstanceName;Initial Catalog=myDataBase;Integrated Security=SSPI;
 
 
Prompt for username and password
This one is a bit tricky. First set the connection object's Provider property to "sqloledb". Thereafter set the connection object's Prompt property to adPromptAlways. Then use the connection string to connect to the database.
oConn.Provider = "sqloledb"
oConn.Properties("Prompt") = adPromptAlways

Data Source=myServerAddress;Initial Catalog=myDataBase;
 
 
Connect via an IP address
Provider=sqloledb;Data Source=190.190.200.100,1433;Network Library=DBMSSOCN;Initial Catalog=myDataBase;User ID=myUsername;Password=myPassword;
DBMSSOCN=TCP/IP. This is how to use TCP/IP instead of Named Pipes. At the end of the Data Source is the port to use. 1433 is the default port for SQL Server.
How to define which network protocol to use
 
Disable connection pooling
This one is usefull when receving errors "sp_setapprole was not invoked correctly." (7.0) or "General network error. Check your network documentation" (2000) when connecting using an application role enabled connection. Application pooling (or OLE DB resource pooling) is on by default. Disabling it can help on this error.

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。