Following are the connection string which we are commonly used in our .Net application with different Data provides, When Data Source is Sql Server 2005/2008
.NET Framework Data Provider for SQL Server
1. Standard Security
Server=ServerName;Database=DataBaseName;User ID=Username;Password=myPassword;Trusted_Connection=False;
Note: if you using SQL Server Express, then replace ServerName with Servername\SQLEXPRESS INSTANCE NAME.
2. Trusted Connection
Data Source=ServerName;Initial Catalog=DataBaseName;Integrated Security=SSPI;
OR
Server=ServerName;Database=DataBaseName;Trusted_Connection=True;
3. Trusted Connection from C drive (Often a Windows C device is not authenticated and logged in to a domain. To use SSPI or trusted connection / authentication from a C device)
Data Source=ServerName;Initial Catalog=DataBaseName;Integrated Security=SSPI;User ID=myDomain\Username;Password=myPassword;
4. Connect via an IP address
Data Source=190.190.200.100,1433;Network Library=DBMSSOCN;Initial Catalog=DataBaseName;User ID=Username;Password=myPassword;
Note: DBMSSOCN=TCP/IP and 1433 is default port of Sql Server.
SQL Server Native Client 10.0 OLE DB Provider
1. Standard Security
Provider=SQLNCLI10;Server=ServerName;Database=DataBaseName;User ID=Username;Password=myPassword;Trusted_Connection=False;
Note: if you using SQL Server Express? Then replace ServerName with Servername\SQLEXPRESS.
2. Trusted Connection
Provider=SQLNCLI10;Server=ServerName;Database=DataBaseName;Trusted_Connection=yes;
3. Connecting to an Sql Server instance
Provider=SQLNCLI10;Server=ServerName\InstanceName;Database=DataBaseName; Trusted_Connection=yes;
4. Enabling MARS(Multiple Active Result Set)
Provider=SQLNCLI10;Server=ServerName;Database=DataBaseName; Trusted_Connection=yes;MARS Connection=True;
SQL Server Native Client 10.0 ODBC Driver
1. Standard Security
Driver={SQL Server Native Client 10.0};Server=ServerName;Database=DataBaseName;Uid=Username;Pwd=myPassword;
Note: if you using SQL Server Express? Then replace ServerName with Servername\SQLEXPRESS.
2. Trusted Connection
Driver={SQL Server Native Client 10.0};Server=ServerName;Database=DataBaseName;Trusted_Connection=yes;
3. Connecting to an Sql Server instance
Driver={SQL Server Native Client 10.0};Server=myServerName\theInstanceName; Database=DataBaseName;Trusted_Connection=yes;
4. Enabling MARS(Multiple Active Result Set)
Driver={SQL Server Native Client 10.0};Server=ServerName;Database=DataBaseName;Trusted_Connection=yes; MARS_Connection=yes;