SqlConnection Connection String Parameter Keywords & Values

I can never find this info, so I'm filing it away.

Name

Default

Description

Application Name

 

The name of the application, or '.Net SqlClient Data Provider' if no application name is provided.

AttachDBFilename
-or-
extended properties
-or-
Initial File Name

 

The name of the primary file, including the full path name, of an attachable database. If this setting is specified, the Initial Catalog setting must also be specified.

The database name must be specified with the keyword 'database'.

Example:
Data Source=.; Initial Catalog=; Integrated Security=true;AttachDBFileName=c:\MyFolder\MyDb.mdf 

Update:

You can use the following syntax to attach a database that lives in your "Data" directory:

AttachDBFileName=|DataDirectory|MyDb.mdf 

Connect Timeout
-or-
Connection Timeout

15

The length of time (in seconds) to wait for a connection to the server before terminating the attempt and generating an error.

Current Language

 

The SQL Server Language record name.

Data Source
-or-
Server
-or-
Address
-or-
Addr
-or-
Network Address

 

The name or network address of the instance of SQL Server to which to connect.

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.

Initial Catalog
-or-
Database

 

The name of the database.

Integrated Security
-or-
Trusted_Connection

'false'

When false, User ID and Password are specified in the connection. When true, the current Windows account credentials are used for authentication.

Recognized values are true, false, yes, no, and sspi (strongly recommended), which is equivalent to true.

Network Library
-or-
Net

'dbmssocn'

The network library used to establish a connection to an instance of SQL Server. Supported values include dbnmpntw (Named Pipes), dbmsrpcn (Multiprotocol), dbmsadsn (Apple Talk), dbmsgnet (VIA), dbmslpcn (Shared Memory) and dbmsspxn (IPX/SPX), and dbmssocn (TCP/IP).

The corresponding network DLL must be installed on the system to which you connect. If you do not specify a network and you use a local server (for example, "." or "(local)"), shared memory is used.

Packet Size

8192

Size in bytes of the network packets used to communicate with an instance of SQL Server.

Password
-or-
Pwd

 

The password for the SQL Server account logging on (Not recommended. To maintain a high level of security, it is strongly recommended that you use the Integrated Security or Trusted_Connection keyword instead.).

Persist Security Info

'false'

When set to false or no (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. Recognized values are true, false, yes, and no.

User ID

 

The SQL Server login account (Not recommended. To maintain a high level of security, it is strongly recommended that you use the Integrated Security or Trusted_Connection keyword instead.).

Workstation ID

the local computer name

The name of the workstation connecting to SQL Server.

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.

Connection Reset

'true'

Determines whether the database connection is reset when being drawn from the pool. For Microsoft SQL Server version 7.0, setting to false avoids making an additional server round trip when obtaining a connection, but you must be aware that the connection state, such as database context, is not being reset.

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.

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.

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.

Published Tuesday, March 22, 2005 10:29 AM by Wayne Allen
Filed under:

Comments

# re: SqlConnection Connection String Parameter Keywords & Values

And don't forget that the filename can be specified as |DataDirectory|filename - this certainly works for AttachDbFilename (eg AttachDbFilename=|DataDirectory|foo.mdf). I don't think many people have discovered that yet.

Tuesday, March 22, 2005 4:59 PM by Dave

# re: SqlConnection Connection String Parameter Keywords & Values

Wednesday, March 23, 2005 7:03 AM by Szokelizer

# re: SqlConnection Connection String Parameter Keywords & Values

I've seen www.connectionstrings.com before, but it dosen't have all the gory details (at least that I've found).

Wednesday, March 23, 2005 11:30 AM by Wayne Allen

# re: SqlConnection Connection String Parameter Keywords & Values

Hmmm, it's the same table both places except for the |DataDirectory| part :)

Friday, March 25, 2005 6:28 AM by Szokelizer

# re: SqlConnection Connection String Parameter Keywords & Values

Friday, March 25, 2005 10:25 AM by Wayne Allen

# re: SqlConnection Connection String Parameter Keywords & Values

Thanks so much, been lookin everywhere for this.

-darren

Wednesday, April 06, 2005 10:41 AM by Darren Kopp

# re:SqlConnection Connection String Parameter Keywords

^_^,Pretty Good!

Sunday, April 10, 2005 10:23 AM by TrackBack

# Need urgent help!!!

I use SqlConnection connection string founded on http://www.connectionstrings.com/ but no one of these strings works. An error occurs "Data source name not found and no default driver specified". What should I do? Please help me!

Thursday, October 12, 2006 5:36 AM by Tom

# re: SqlConnection Connection String Parameter Keywords & Values

Could you provide a little more information? What is the connection string you are trying?

Friday, October 13, 2006 12:42 PM by Wayne Allen

# re: SqlConnection Connection String Parameter Keywords & Values

Why doesn't the Application Name parameter work? I want to use it so the SQL Server Activity Monitor will identify my application instead of showing .NET SqlClient Data Provider.

Monday, June 25, 2007 1:59 PM by Robert S. Robbins

# re: SqlConnection Connection String Parameter Keywords & Values

what about allowed values for the 'mode' attribute?

Wednesday, April 02, 2008 6:46 AM by lapa

# re: SqlConnection Connection String Parameter Keywords & Values

I'd be glad to add the mode attribute, but I can't find any reference to it, other than in ODBC 1.0.

Wednesday, April 02, 2008 12:46 PM by Wayne Allen

# re: SqlConnection Connection String Parameter Keywords & Values

how can I know the connection string parameters for a given database?

When I open a data grid in .NET it would identify the available servers. There should be a way to get this string in other means.

I can not use data grid to access the database because it complains about login.

Thursday, October 16, 2008 6:16 PM by Bill

# re: SqlConnection Connection String Parameter Keywords & Values

Thanks so much i was desperate for this, because connection string effects much in SQL transaction performance.

Friday, November 28, 2008 1:10 AM by Yasir Akram

# re: SqlConnection Connection String Parameter Keywords & Values

its very nice.

but i have a problem....

scenario of my application is that whenever server is down or dere is no connection then my application run in the specific defined way else work in the mentioned way....

but m unable to do this if and else

kindly how the connection will be cheked except

"connection.state"

coz i think it searches for connection.open or connection.close to be implemented

Wednesday, December 31, 2008 2:13 AM by sidra

# Triggers | hilpers

Pingback from  Triggers | hilpers

Tuesday, January 20, 2009 2:47 PM by Triggers | hilpers

# Different connection strings - SQL Server « Systems Engineering and RDBMS

Pingback from  Different connection strings - SQL Server « Systems Engineering and RDBMS

Leave a Comment

(required) 
(required) 
(optional)
(required)