We already know that ASP.NET uses ADO.NET to access the database, access to the Access database via OLEDB - we are very commonly used in one of the low-end databases. This article discusses a number of error prompts that may see in ASP.NET, see the database files created from Access 2000 and Access XP, and there is less than an error message when an error occurs. I hope to be helpful. Another point is that you want to pass this article, you have a new understanding of NTFS permissions for ASP.NET in ASP.NET. (1) The experiment process is convenient to describe, and gives a specific example to do an experiment: the application is / test, the data inventory is placed in D: / wwwroot/test/data/db1.mdb, we already know in the ASP.NET in one If you call the ASPNET virtual user, we need to give this account with a specific NTFS permission to make the ASP.NET program running normally. In order to get the most stringent NTFS permission settings, we give the minimum NTFS permissions when the experiment begins: a) D: / wwwroot / test / data / folder to the user ASPNET as follows:
Allow full control □ □ Modify □ □ reading and run √ □ listing folder directory √ □ Read √ □ write □□
b) D: /wwwroot/test/data/db1.mdb file itself gives the user ASPNET to the following permissions: √ Allow the propagation of the inheritance from the parent system to this object 1.1 For an ASPX program containing only "select" command The above permissions are set to run when running, namely: the above permissions have met the operation of such programs. 1.2 For an ASPX program containing commands such as "update" "INSERT" UPDATE ", (a) If db1.mdb is the database created by Access 2000, the following error:" / Test "application server error. --------------------------------------- Microsoft Jet Database Engine can't open file 'D: / wwwroot / test / data / '. It has been opened by other users, or no access to data. Description: Execute an unprocessed exception during the current web request. Check the stack tracking information to learn more about the error and the code caused in the code. Abnormal Details: System.Data.Oledb.oledBException: Microsoft Jet Database Engine does not open file 'D: / wwwroot / test / data /'. It has been opened by other users, or no access to data. (b) If db1.mdb is the database created by Access XP, the following error appears: "/ test" server error. ---------------------------------------------- Operation must use one Update query. Description: Execute an unprocessed exception during the current web request. Check the stack tracking information to learn more about the error and the code caused in the code. Abnormal Details: System.Data.Oledb.oledBException: Action must use an updateable query. (c) Cause Preliminary analysis: Because including "Update" "INSERT" "UPDATE", you need to write a write operation on the database file itself, so the above permissions cannot meet this requirement, and we need to further release permissions. We release some privileges, a) d: / wwwroot / test / data / folder constant: b) D: /wwwroot/test/data/db1.mdb file itself gives the user ASPNET to the following permissions: Allow refusal to complete control □ □ Modification □ □ Reading and Run √ □ List Folder Directory √ □ Read √ □ Write √ □
1.3 Continue experimentation after disconnection
(a) If db1.mdb is the database created by Access 2000, the following error appears:
Server errors in the "/ TEST" application.
------------------------------------------
Can't lock the file.
Description: Execute an unprocessed exception during the current web request. Check the stack tracking information to learn more about the error and the code caused in the code. Abnormal Details: System.Data.Oledb.oledBexception: You cannot lock the file.
(b) If db1.mdb is the database created by Access XP, there is no error.
(c) Cause Preliminary analysis: We found that when opening the Access database, we will generate a * .ldb file in the directory, which is an Access's lock tag. In view of this, when we guess, when the user ASPNET accesss the Access database, it is also necessary to generate a lock tag, and the directory does not allow it to write, so an error. As for the database created by Access XP, why not know this error, the reason is not known. We further release the permissions, a) D: / wwwroot / test / data / folder to the user ASPNET as follows:
Allow full control □ □ Modify □ □ reading and run √ □ listing folder directory √ □ Read √ □ write √ □ b) D: /wwwroot/test/data/db1.mdb file itself gives user ASPNET The following permissions: √ Allow the propagation of the inheritance from the parent to this object
1.4 Continue experimentation, discovering the error has been resolved, then this permissions are the "minimum authority" we need to release.
(a) If db1.mdb is a database created by Access 2000, we will find a small problem: generated * .ldb files do not delete themselves, the file still exists after access, but this problem does not affect the normal ASP.NET run.
(b) If db1.mdb is the database created by Access XP, there is no similar problem.
(c) Cause Preliminary analysis: We just gave the ASPNET to write the authority of the folder, did not give it the permissions to modify, so once the file was written, it could not modify its content, *. ldb also deleted it.
If you do not solve this problem, further release of permissions is: a) d: / wwwroot / test / data / folder to the user ASPNET as follows:
Allow full control □ □ Modify √ □ Read and run √ □ listing folder Directory √ □ Read √ □ Write √ □ b) D: /wwrow/test/data/db1.mdb file itself gives user ASPNET The following permissions: √ Allow the propagation of the inheritance from the parent to this object
1.5 Announced, the experiment: We use db1.mdb to open edit in Access, and access ASP.NET.
(a) If db1.mdb is the database created by Access 2000, we have found that there is no problem.
(b) If db1.mdb is the database created by Access XP, the following error appears:
Server errors in the / zhao application.
------------------------------------------------
Can't use ''; files are already in use.
Description: Execute an unprocessed exception during the current web request. Check the stack tracking information to learn more about the error and the code caused in the code. Abnormal Details: System.Data.Oledb.oledBexception: You cannot use ''; files are already in use.
(c) Cause Preliminary analysis: Access database is a single-user single-threaded database. When we open an edit database file in Access, it is actually in the current Windows user (such as Administrator), and ASP.NET uses ASPNET virtual User (belonging to the user group), the level is lower than the Administrator, cannot be "robbed", so there is a conflict error. As for the case of Access 2000 Ignore this problem, we don't have to discuss it, it may be that access 2000 does not consider so many factors. 1.6 Reconside a situation: change the attribute of db1.mdb to "read only", whether it is Access 2000 or Access XP
Appears in 1.2, respectively
Error prompts of their respective errors.
(2) Experimental conclusion
1. We first summarize the origin of the NTFS permission settings of the Access database file: in the ASP.NET, the default is to access the identity of the virtual user called ASPNET, you can manipulate the database, you can manage the control panel - "management Tools "- Computer Management -" Local User and Group "-" User "See this user, by default: full name: ASP.NET computer account description as: used to run an ASP.NET assist process (ASPNET_WP The account of .exe. Belong to: Users group. With such a user who belongs to the User group to perform file operations, the risk of database operation is much smaller than the risk of users with an Administrators group, which is also a consideration of ASP.NET in security. Since it is such a user who needs access, the database file itself needs, then we need to give it a certain NTFS permission to allow it to access. Obviously there is no NTFS permission license, ASPNET cannot access, operate the database, will appear in the above experiment. 2. After the above experiment, we already know that the following NTFS permission settings can meet the general needs: a) D: / wwwroot / test / data / folder to the user ASPNET as follows: