String str = @ "Data source=.\sqlexpress;integrated Security=sspi; Attachdbfilename=z:\ttt.mdf; User Instance=true ";
Where the user instance=true parameter is not limited.
Http://www.cnblogs.com/yuanyuan/archive/2011/02/12/1951871.html
The default value of Integrated security is false, the UID and PWD are required at this time, the database will be logged in as SQL Server user, and if it is set to True,yes or SSPI, this cannot appear uid and PWD, and the Windows user Provincial landing database. It is highly recommended to use the latter form for higher security.
User Instance
Once, to run the SQL Server database, you have to create the database under the instance, whether it is directly created, or attached, or restored, in short, it must be created under the instance, but this causes a problem, our permissions are not high enough to attach or restore the database to SQL Server, we just have. mdf ,. ldf files.
Starting with SQL Server 2005, you have a new selection
Using AttachDbFileName in the connection string, you can connect directly to a database file. For example, this is:
Data source=.\sqlexpress; attachdbfilename=| Datadirectory|\data.mdf;integrated security=true; User Instance=true
Here the user Instance is the users instance, which is True to indicate the use of the user instance.
C # Connect SQL Server database files as additional files