Sql server 2005 connection string

Standard Connection str: (Sql server authentication)
"Data Source=stone;Initial Catalog=pubs;User Id=sa;Password=;"
   - or -
"Server=stone;Database=pubs;User ID=sa;Password=asdasd;Trusted_Connection=False"

 Trusted Connection: (WinNT authentication)
"Data Source=stone\instance;Initial Catalog=pubs;Integrated Security=SSPI;"
   - or -
"Server=stone\instance;Database=pubs;Trusted_Connection=True;"

Connect via an IP address:
"Data Source=127.0.0.1;Network Library=DBMSSOCN;Initial Catalog=pubs;User ID=sa;Password=;"

 Enabling MARS (multiple active result sets):
"Server=stone;Database=pubs;Trusted_Connection=True;MultipleActiveResultSets=true"

Attach a database file on connect to a local SQL Server Express instance:
"Server=.\SQLExpress;AttachDbFilename=c:\abc\mydb.mdf;Database=dbname;Trusted_Connection=Yes;"
   - or -
"Server=.\SQLExpress;AttachDbFilename=|DataDirectory|mydb.mdf;Database=dbname;Trusted_Connection=Yes;"

Using "User Instance" on a local SQL Server Express instance:
"Data Source=.\SQLExpress;integrated security=true;attachdbfilename=|DataDirectory|\mydb.mdf;user instance=true;"
The "User Instance" functionality creates a new SQL Server instance on the fly during connect. This works only on a local SQL Server 2005 instance and only when connecting using windows authentication over local named pipes. The purpose is to be able to create a full rights SQL Server instance to a user with limited administrative rights on the computer. To enable the functionality: sp_configure 'user instances enabled','1' (0 to disable)

原文地址:https://www.cnblogs.com/stone/p/1238407.html