C # Connect SQL Server database files as additional files

Source: Internet
Author: User


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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.