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.