All SQL Server SqlConnection properties
There are plenty of combinations when creating an SQL Server connection string. This reference table explains each option available per keyword.
Introduction
This table shows all connection string properties for the ADO.NET SqlConnection object. Most of the properties are also used in ADO. Using this table will give you a better understanding of the options available.
The Properties
Some of the keywords have several equivalents. For those, each variant is specified on its own line separated with "-or-".
Name |
Default |
Description |
Application Name |
The name of the application, or '.Net SqlClient Data Provider' if no applicationname is provided. |
|
Async |
'false' |
When true, enables asynchronous operation support. Recognized values are true, false, yes, and no. |
AttachDBFilename |
The name of the primary database file, including the full path name of an attachable database. AttachDBFilename is only supported for primary data files with an .mdf extension. The attachment will fail if the primary data file is read-only. The path may be absolute or relative by using the DataDirectory substitution string. If DataDirectory is used, the database file must exist within a subdirectory of the directory pointed to by the substitution string. |
|
Connect Timeout |
15 |
The length of time (in seconds) to wait for a connection to the server before terminating the attempt and generating an error. |
Connection Lifetime |
0 |
When a connection is returned to the pool, its creation time is compared with the current time, and the connection is destroyed if that time span (in seconds) exceeds the value specified by Connection Lifetime. This is useful in clustered configurations to force load balancing between a running server and a server just brought online. A value of zero (0) causes pooled connections to have the maximum connection timeout. |
Context Connection |
'false' |
true if an in-process connection to SQL Server should be made. |
Connection Reset |
'true' |
Determines whether the database connection is reset when being removed from the pool. Setting to 'false' avoids making an additional server round-trip when obtaining a connection, but the programmer must be aware that the connection state is not being reset. |
Current Language |
The SQL Server Language record name. |
|
Data Source |
The name or network address of the instance of SQL Server to which to connect. The port number can be specified after the server name: server=tcp:servername, portnumber. When specifying a local instance, always use (local). To force a protocol, add one of the following prefixes: np:(local), tcp:(local), lpc:(local) |
|
Encrypt |
'false' |
When true, SQL Server uses SSL encryption for all data sent between the client and server if the server has a certificate installed. Recognized values are true, false, yes, and no. |
Enlist |
'true' |
When true, the pooler automatically enlists the connection in the creation thread's current transaction context. Recognized values are true, false, yes, and no. |
Failover Partner |
N/A |
The name of the failover partner server where database mirroring is configured. The Failover Partner keyword is not supported by .NET Framework version 1.0 or 1.1. |
Initial Catalog |
The name of the database. |
|
Load Balance Timeout |
0 |
The minimum time, in seconds, for the connection to live in the connection pool before being destroyed. |
MultipleActiveResultSets |
'false' |
When true, an application can maintain multiple active result sets (MARS). When false, an application must process or cancel all result sets from one batch before it can execute any other batch on that connection. Recognized values are true and false. The keyword is not supported by .NET Framework version 1.0 or 1.1. |
Integrated Security |
'false' |
Whether the connection is to be a secure connection or not. Recognized values are 'true', 'false', and 'sspi', which is equivalent to 'true'. |
Max Pool Size |
100 |
The maximum number of connections allowed in the pool. |
Min Pool Size |
0 |
The minimum number of connections allowed in the pool. |
Network Library |
'dbmssocn' |
The network library used to establish a connection to an instance of SQL Server. Supported values include dbnmpntw (Named Pipes), dbmsrpcn (Multiprotocol, Windows RPC), dbmsadsn (Apple Talk), dbmsgnet (VIA), dbmslpcn (Shared Memory, local machine only) and dbmsspxn (IPX/SPX), dbmssocn (TCP/IP) and Dbmsvinn (Banyan Vines). |
Packet Size |
8192 |
Size in bytes of the network packets used to communicate with an instance of SQL Server. |
Password |
The password for the SQL Server account logging on. Not used with (the strongly recommended) 'Integrated Security=true' option. |
|
Persist Security Info |
'false' |
When set to 'false' (strongly recommended), security-sensitive information, such as the password, is not returned as part of the connection if the connection is open or has ever been in an open state. Resetting the connection string resets all connection string values including the password. |
Pooling |
'true' |
When true, the SQLConnection object is drawn from the appropriate pool, or if necessary, is created and added to the appropriate pool. Recognized values are true, false, yes, and no. |
Replication |
'false' |
true if replication is supported using the connection. |
Transaction Binding |
Implicit Unbind |
Controls connection association with an enlisted System.Transactions transaction. Possible values are: |
TrustServerCertificate |
'false' |
When set to true, SSL is used to encrypt the channel when bypassing walking the certificate chain to validate trust. If TrustServerCertificate is set to true and Encrypt is set to false, the channel is not encrypted. Recognized values are true, false, yes, and no. |
Type System Version |
N/A |
A string value that indicates the type system the application expects. Possible values are: |
User ID |
The SQL Server login account. |
|
User Instance |
'false' |
A value that indicates whether to redirect the connection from the default SQL Server Express instance to a runtime-initiated instance running under the account of the caller. |
Workstation ID |
The local computer name |
The name of the workstation connecting to SQL Server. |
Summary
There is no point in always defining each of these properties. Return to this sheet to look up definitions as a way to ensure proper connections. Also use this as a reference to ensure that you have included every property applicable to your specific situation.