How to append database files in ASP. NET to iis7 without causing SQL Server errors

Source: Internet
Author: User
Tags connectionstrings

Vs2010 provides an extremely convenient way for ASP. NET development. In particular, it allows you to directly put database files under the project file and app_data, and integrates various operation data windows of SQL Server Management studio. And write the database connection string to the Web. config configuration file. As follows:

<Connectionstrings> <br/> <Add name = "applicationservices" connectionstring = "Data Source =. /sqlexpress; Integrated Security = sspi; attachdbfilename = | datadirectory |/aspnetdb. MDF; user instance = true "providername =" system. data. sqlclient "/> <br/> <Add name =" connectionstring "connectionstring =" Data Source =. /sqlexpress; attachdbfilename = | datadirectory |/computerrepair. MDF; Integrated Security = true; Connect timeout = 30; user instance = true "providername =" system. data. sqlclient "/> <br/> </connectionstrings> <br/>

In this way, the database is completely self-contained by the project. You can copy the website project to any place to run it. For example, to copy data to an IIS website, you must take two steps:

 

(1) iis7: The application pool used on this site must load the user configuration file. The procedure is as follows: right-click the application pool used --> advanced settings --> Process Model --> load the user configuration file --> true.

 

(2) Right-click the database file under the app_data directory in exploer (my files are computerrepair. MDF and computerrepair. LDF) and set its attributes so that everyone has the permission to read and write the two files. Because the account that starts the SQL Server service may not have the permission to read and write database files, it may fail.

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.