SQL Server express database connection configuration in the web. config file

Source: Internet
Author: User
Tags sql server express
For the sqlserverexpress database connection configuration, I have seen it several times before. I have seen it again in an open-source software this morning. I feel it is necessary to have a clear understanding of it, example:
<Add name = "localsqlserver" connectionstring = "Data Source =. \ sqlexpress; Integrated Security = true; attachdbfilename = | datadirectory | timetracker. MDF; user instance = true" />
Connectionstring is used when sqlconnectionstringbuilder is instantiated, for example, sqlconnectionstringbuild builder = new sqlconnectionstringbuild (connectionstring ).

I. Data Source
The datasource attribute of sqlconnectionstringbuilder corresponds to data source in connectionstring. "Data Source" can be replaced by the following strings: "server", "Address", "ADDR", and "network address ".
Data Source =. \ sqlexpress can also be written as Data Source = (local) \ sqlexpress.

II,Integrated Security
The integratedsecurity attribute of sqlconnectionstringbuilder corresponds to the Integrated Security in connectionstring. "Integrated Security" can be written as "trusted_connection". If it is true, the current Windows Account creden are used for authentication. If it is false, you must specify the user ID and password in the connection.

III,Attachdbfilename
The attachdbfilename attribute of sqlconnectionstringbuilder corresponds to attachdbfilename in connectionstring. "attachdbfilename" can be written as "extended properties" and "initial file name ". The attachdbfilename attribute specifies the location of the database files dynamically appended to the server when the connection is opened. This attribute can accept the full path and relative path of the database (for example, | datadirectory | syntax). This path will be applied at runtime.ProgramThe app_data directory.
One articleArticleSpecifically, what is "datadirectory" and "datadirectory?

4. user instance
the userinstance attribute of sqlconnectionstringbuilder corresponds to the user instance in connectionstring, this value indicates whether to redirect the connection from the default SQL Server express instance to the instance that runs under the caller account and starts at runtime. Userinstance = true. In this case, sqlserverexpress creates a new process to attach the database to a new instance and runs it under the user identity that opens the connection. In ASP. NET applications, this user is a local ASPNET account or the default networkservice, which depends on the operating system. To securely append database files provided by non-system administrator accounts (such as ASP. NET accounts), it is necessary to create an independent sqlserver user instance.

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.