What is DataDirectory?

Source: Internet
Author: User

ASP.net 2.0 has a special directory app_data, usually the SQL Server, express data file is placed in this directory, the corresponding database connection string is:
Connectionstring= "... data source=./sqlexpress;integrated Security=sspi; attachdbfilename=| Datadirectory|data.mdf; User Instance=true "
Here's a DataDirectory macro, what does he mean?

DataDirectory is a replacement string that represents the database path. Because there is no need to hard-code the full path, DataDirectory simplifies the sharing of the project and the deployment of the application. For example, you do not need to use the following connection string:
"Data source= c:/program files/myapp/app_data/mydb.mdf"
By using | Datadirectory| (included in the vertical bar shown below), you can have the following connection string:
"Data Source = | Datadirectory|/mydb.mdf "
Here's an article working with the local databases detailing the meaning of datadirectory, not only in SQL Server Express, but also in other file databases. For example, the connection string for a sqllite database file:
<add name= "Defaultdb"
Connectionstring= "Driverclass=nhibernate.driver.sqlite20driver;dialect=nhibernate.dialect.sqlitedialect;data source=| Datadirectory|/data.db3 "/>

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.