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
![]() |
|
---|---|
|
![]() |
|
---|---|
|
![]() |
---|
In place of Trusted_Connection=yes, you can use Integrated Security=SSPI. |
![]() |
|
---|---|
"Driver={SQL Native Client};Server=DataSrvr1;Database=pubs;Trusted_Connection=yes;MARS_Connection=yes" |
![]() |
---|
In place of MultipleActiveResultSets=true, you can use MARS_Connection=yes. |
![]() |
|
---|---|
"Driver={SQL Native Client};Server=DataSrvr1;Database=pubs;Trusted_Connection=yes;Encrypt=yes" |
SQL Native Client OLE DB Provider
![]() |
|
---|---|
"Provider=SQLNCLI;Server=DataSrvr1;Database=pubs;UID=myUsername;PWD=myPassword;" |
![]() |
|
---|---|
"Provider=SQLNCLI;Server=DataSrvr1;Database=pubs;Trusted_Connection=yes;" |
![]() |
---|
In place of Trusted_Connection=yes, you can use Integrated Security=SSPI. |
![]() |
|
---|---|
"Provider=SQLNCLI;Server=DataSrvr1;Database=pubs;Trusted_Connection=yes;MarsConn=yes" |
![]() |
---|
In place of MarsConn=yes, you can use either MultipleActiveResultSets=true or MARS_Connection=yes. |
![]() |
|
---|---|
"Provider=SQLNCLI;Server=DataSrvr1;Database=pubs;Trusted_Connection=yes;Encrypt=yes" |
SqlConnection (.NET 2.0)
![]() |
|
---|---|
"Data Source=DataSrvr1;Initial Catalog=pubs;User Id=myUsername;Password=myPassword;" "Server=DataSrvr1;Database=pubs;User ID=myUsername;Password=myPassword;Trusted_Connection=False" |
![]() |
---|
Both of the above connection strings will produce the same result. |
![]() |
|
---|---|
"Data Source=DataSrvr1;Initial Catalog=pubs;Integrated Security=SSPI;" "Server=DataSrvr1;Database=pubs;Trusted_Connection=True;" |
![]() |
---|
Both of the above connection strings will produce the same result. |
![]() |
|
---|---|
"Data Source=190.200.70.100,1433;Network Library=DBMSSOCN;Initial Catalog=pubs; User ID=myUsername;Password=myPassword;" |
![]() |
---|
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. |
![]() |
|
---|---|
"Server=DataSrvr1;Database=pubs;Trusted_Connection=True;MultipleActiveResultSets=true" |