Dundas Chart for SharePoint Send comments on this topic.
SQLServer Connection Strings
See Also

Glossary Item Box

Overview

This article provides you with examples of the connection strings used to connect to some common SQLServer 2005 data providers. It is worthy to note that each connection is different, therefore it is usually up to the server administrator to create and deploy the correct connection string for each application, user account, and type.

SQL Native Client ODBC Provider

Copy Code Standard Security
"Driver={SQL Native Client};Server=DataSrvr1;Database=pubs;UID=myUsername;PWD=myPassword;"

 

Copy Code Trusted Connection
"Driver={SQL Native Client};Server=DataSrvr1;Database=pubs;Trusted_Connection=yes;"

 

Note
In place of Trusted_Connection=yes, you can use Integrated Security=SSPI.

 

Copy Code Enabling MARS (Multiple Active Result Sets)
"Driver={SQL Native Client};Server=DataSrvr1;Database=pubs;Trusted_Connection=yes;MARS_Connection=yes"

 

Note
In place of MultipleActiveResultSets=true, you can use MARS_Connection=yes.

 

Copy Code Encrypt Data Sent Over Network
"Driver={SQL Native Client};Server=DataSrvr1;Database=pubs;Trusted_Connection=yes;Encrypt=yes"

 

SQL Native Client OLE DB Provider

Copy Code Standard Security
"Provider=SQLNCLI;Server=DataSrvr1;Database=pubs;UID=myUsername;PWD=myPassword;"

 

Copy Code Trusted Connection
"Provider=SQLNCLI;Server=DataSrvr1;Database=pubs;Trusted_Connection=yes;"

 

Note
In place of Trusted_Connection=yes, you can use Integrated Security=SSPI.

 

Copy Code Enabling MARS (Multiple Active Result Sets)
"Provider=SQLNCLI;Server=DataSrvr1;Database=pubs;Trusted_Connection=yes;MarsConn=yes"

 

Note
In place of MarsConn=yes, you can use either MultipleActiveResultSets=true or MARS_Connection=yes.

 

Copy Code Encrypt Data Sent Over Network
"Provider=SQLNCLI;Server=DataSrvr1;Database=pubs;Trusted_Connection=yes;Encrypt=yes"

 

SqlConnection (.NET 2.0)

Copy Code Standard Security
"Data Source=DataSrvr1;Initial Catalog=pubs;User Id=myUsername;Password=myPassword;" 

"Server=DataSrvr1;Database=pubs;User ID=myUsername;Password=myPassword;Trusted_Connection=False"

 

Note
Both of the above connection strings will produce the same result.

 

Copy Code Trusted Connection
"Data Source=DataSrvr1;Initial Catalog=pubs;Integrated Security=SSPI;"

"Server=DataSrvr1;Database=pubs;Trusted_Connection=True;"

 

Note
Both of the above connection strings will produce the same result.

 

Copy Code Connect Using An IP Address
"Data Source=190.200.70.100,1433;Network Library=DBMSSOCN;Initial Catalog=pubs;
User ID=myUsername;Password=myPassword;"

 

Note
Immediately following the IP address above is the port number to use. The port value of 1433 is the default. Also, you can use Network Library=DBMSSOCN to use TCP/IP instead of using named pipes.

 

Copy Code Enabling MARS (multiple active result sets)
"Server=DataSrvr1;Database=pubs;Trusted_Connection=True;MultipleActiveResultSets=true"

See Also