Microsoft Knowledge Base Article
This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved.
Terms
of Use |
Trademarks
Article ID: 316675 - Last Review: May 13, 2007 - Revision: 6.4
An unhandled exception may occur when you try to connect to an Access database from an ASP.NET worker process
This article was previously published under Q316675
This article refers to the following Microsoft .NET
Framework Class Library namespace:
On This Page
SYMPTOMS
An unhandled exception may occur under the following
circumstances:
- An ASP.NET worker process (Aspnet_wp.exe) runs under the
default ASPNET account.
-and-
- You do not enable impersonation on that application.
-and-
- You try to connect to or write to an Access
database.
Under these circumstances, you may receive one of the following
exceptions:
The Microsoft Jet database engine cannot
open the file 'C:\Nwind.mdb'. It is already opened exclusively by another user,
or you need permission to view its data.
Operation must use an updateable query.
CAUSE
Because of security concerns, the ASP.NET worker process
runs under the default ASPNET account. If you do not enable impersonation for
an application, all of the threads that run the requests for that application
run under the process account.
This problem occurs because the ASPNET
account does not have sufficient permissions to connect to or write to an
Access database.
RESOLUTION
To work around this problem, use one of the following
methods:
- Configure the ASP.NET worker process to run under the
SYSTEM account in the <processModel> section of the Machine.config
file.
- For security reasons, Microsoft recommends that you enable
impersonation on your ASP.NET application. This method works if the
impersonated user has necessary permissions to the computer and the database
that you are accessing.
- Grant read and write permissions for the "Everyone" group
on the database and the database folder. This method is not safe; therefore,
Microsoft does not recommend this method.
STATUS
This
behavior is by design.
MORE INFORMATION
When you need unlimited users, full-time support, and ACID
transactions, Microsoft strongly recommends that you use Microsoft SQL Server
with Microsoft Internet Information Services (IIS). Although Microsoft Active
Server Pages (ASP) works with any OLE DB-compliant or ODBC-compliant database,
IIS has been extensively tested. IIS is designed to work with Microsoft SQL
Server on high transaction traffic and with unlimited users, which can occur in
an Internet scenario.
Note "ACID" is an acronym for the four properties of
transaction-processing systems: Atomicity, Consistency, Isolation,
Durability.
ASP supports the use of the Microsoft Jet database engine
as a valid data source. However, Microsoft ODBC Driver for Access and Microsoft
OLE DB Provider for Jet are not intended for use with high-stress,
high-concurrency, full-time server applications (such as Web applications,
commerce applications, transactional applications, messaging servers, and so
on).
Steps to reproduce the behavior
- Create a new ASP.NET Web Application project in Microsoft
Visual C# .NET.
- Add the following code to the "Declaration" section of your
Web Form, which appears at the top of the Code window:
- Add the following code to the Page_Load event:
String myConn ="Provider=Microsoft.JET.OLEDB.4.0;Data Source=C:\\Nwind.mdb;";
String myQuery = "Insert into Customers(CustomerID,CompanyName) Values ('aaaaa', 'aaaaa')";
OleDbConnection cn = new OleDbConnection(myConn);
cn.Open();
OleDbCommand cmd = new OleDbCommand(myQuery, cn);
cmd.ExecuteNonQuery();
cn.close();
- Modify the connection string as appropriate for your
environment.
- Compile the project.
- View WebForm1.aspx in your browser. Notice that you receive
one of the above-mentioned exceptions.
REFERENCES
For additional information, click the following article numbers to view the articles in the Microsoft Knowledge Base:
306590Â
(http://kbalertz.com/Feedback.aspx?kbNumber=306590/
)
ASP.NET security overview
307626Â
(http://kbalertz.com/Feedback.aspx?kbNumber=307626/
)
ASP.NET configuration overview
For more information about the
<processModel> section, visit the following Microsoft Developer Network (MSDN)
Web site:
APPLIES TO
- Microsoft ADO.NET 2.0
- Microsoft ADO.NET 1.0
- Microsoft ASP.NET 1.0
- Microsoft Access 2002 Standard Edition
- Microsoft Access 2000 Standard Edition
- Microsoft Office FrontPage 2003
| kbtshoot kberrmsg kbnofix kbprb kbsystemdata KB316675 |
Community Feedback System
Very often, it takes hours to solve a problem. Very often, you've looked high
and low, and have tried a lot of solutions. When you finally found it, chances
are, it was because someone else helped you. Here's your chance to give back.
Use our community feedback tool to let others know what worked for you and what
didn't.
Please also understand that the community feedback system is not warranted to be
correct, it's simply a system that we've built to let people try and help each
other. If something in a feedback response doesn't make sense to you, or you're
not comfortable making changes that the feedback talks about (like registry
edits), please consult a professional.
Thank you for using kbAlertz.com Feedback System.
-- Scott Cate
Be the first to leave feedback, to help others about this knowledge base
article.
(Optional) Name
(Optional)
Public URL Or Email
Comments
No
HTML -- Text Only Please