Connection strings for SQL Server 2008

时间:2023-01-19 15:52:53

More information about connection strings at: http://www.connectionstrings.com/sql-server-2008

1.Sandard Security
Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;

2.Standard Security alternative syntax
Server=myServerAddress;Database=myDataBase;UserID=myUsername;Password=myPassword;Trusted_Connection=False;
3.Trusted Connection
Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;
4.Trusted Connection alternative syntax
Server=myServerAddress;Database=myDataBase;Trusted_Connection=True;
5.Connecting to an SQL Server instance
Server=myServerName\theInstanceName;Database=myDataBase;Trusted_Connection=True;
6.Trusted Connection from a CE device
DataSource=myServerAddress;InitialCatalog=myDataBase;IntegratedSecurity=SSPI;UserID=myDomain\myUsername;Password=myPassword;
7.Connect via an IP address
DataSource=190.190.200.100,1433;NetworkLibrary=DBMSSOCN;InitialCatalog=myDataBase;UserID=myUsername;Password=myPassword;
8.Enabling MARS (multiple active result sets)
Server=myServerAddress;Database=myDataBase;Trusted_Connection=True;MultipleActiveResultSets=true;
9.Attach a database file on connect to a local SQL Server Express instance
Server=.\SQLExpress;AttachDbFilename=c:\asd\qwe\mydbfile.mdf;Database=dbname;Trusted_Connection=Yes;
10.Attach a database file, located in the data directory, on connect to a local SQL Server Express instance
Server=.\SQLExpress;AttachDbFilename=|DataDirectory|mydbfile.mdf;Database=dbname;Trusted_Connection=Yes;
11.Using an User Instance on a local SQL Server Express instance
DataSource=.\SQLExpress;IntegratedSecurity=true; AttachDbFilename=|DataDirectory|\mydb.mdf;User Instance=true;
12.Database mirroring
DataSource=myServerAddress;FailoverPartner=myMirrorServerAddress;InitialCatalog=myDataBase;Integrated Security=True;

13.Asynchronous processing
Server=myServerAddress;Database=myDataBase;IntegratedSecurity=True;AsynchronousProcessing=True;