Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

"System.Data.OleDb.OleDbException" error when you run an ASP.NET Web application


View products that this article applies to.

Symptoms

When you connect to a Microsoft Access database from a Microsoft ASP.NET application, you receive the following error message:
System.Data.OleDb.OleDbException: Unspecified error

↑ Back to the top


Cause

The ASP.NET Web application that has the impersonation element set to true in the Web.config file, and that has the authentication element set to Windows in the Web.config file, runs under the impersonated account. The code in the ASP.NET Web application connects to an Access database. When the connection is made, the Microsoft Jet OLE DB creates temporary files in the Temp folder in the following directory:
Document and Settings\ServerName\ASPNET\Local settings
where ServerName is the name of your server.

If the impersonated user account does not have read/write permissions enabled in the Temp folder, you receive the error message that is mentioned in the "Symptoms" section.

↑ Back to the top


Resolution

To resolve this problem, enable read/write permissions for the impersonated user account in the Temp folder. To do this, follow these steps:
  1. In Windows Explorer, locate the following folder:
    Document settings\ServerName\ASPNET\Local settings\Temp
    where ServerName is the name of your server.
  2. Right-click the Temp folder, and then click Properties.
  3. In the Properties dialog box, click the Security tab.
  4. On the Security tab, click Add, and then type ServerName\UserAccount in the Select Users or Groups text box, where ServerName is the name of your server, and where UserAccount is the name of the impersonated account. Click OK.
  5. Click to select the Read and the Write check boxes, and then click OK.

↑ Back to the top


Status

This behavior is by design.

↑ Back to the top


More information

Steps to Reproduce the Behavior

  1. Create a new ASP.NET Web application. To do this, follow these steps:
    1. Start Microsoft Visual Studio .NET.
    2. Create a new Microsoft Visual C# .NET or a new Microsoft Visual Basic .NET ASP.NET Web Application. Name the project SampleApplication.
    3. Write the code in the SampleApplication file to connect to the Access database.
  2. Set the authentication mode to Windows. To do this, follow these steps:
    1. In Solution Explorer, double-click Web.config.
    2. Under the <System.web> section, modify the authentication element as follows:
        <authentication mode="Windows" /> 
  3. Set the impersonation element to true. To do this, follow these steps:
    1. Under the <System.web> section, add the impersonation element as follows:
      <identity impersonate="true" />
      
    2. Save, and then close the Web.config file.
  4. On the Build menu, click Build SampleApplication.
  5. Set the authentication method on the application. To do this, follow these steps:
    1. Click Start, and then click Run.
    2. In the Open text box, type inetmgr, and then click OK.
    3. In the Internet Information Services dialog box, click Default Web Site.
    4. Right-click SampleApplication, and then click Properties.
    5. In the SampleApplication Properties dialog box, click the Directory Security tab.
    6. Under Anonymous access and authentication control, click Edit.
    7. In the Authentication Methods dialog box, click to select the Anonymous Access check box. Make sure that the User name text box has the UserAccount value, where UserAccount is a Windows account. Click OK two times, and then close the Internet Information Services dialog box.
    8. Make sure that read/write permissions for UserAccount are not enabled in the following folder:
      Document settings\ServerName\ASPNET\Local Settings\Temp
    Note IIS uses the following authentication methods to authenticate against the ASP.NET Web application:
    • Anonymous Authentication: IIS uses the IIS anonymous user account (the default account is IUSR_computername).
    • Integrated Authentication: IIS uses the user account of the user who is currently logged on.
    • Basic Authentication: IIS uses the user-specified account.
  6. Run the application. To do this, type http://<ServerName>/SampleApplication/Webform1.aspx in the Address bar of the Web browser, and then click Go.

    You may see the error message that is mentioned in the "Symptoms" section.

↑ Back to the top


References

For more information about ASP.NET impersonation, visit the following Microsoft Developer Network (MSDN) Web site: For more information, click the following article numbers to view the articles in the Microsoft Knowledge Base:
301195 How to configure security for files and folders on a network (domain) in Windows 2000
316675 Cannot connect to Access database from ASP.NET

↑ Back to the top


Keywords: kbwebforms, kbauthentication, kbconfig, kbprb, kbdatabase, KB825738

↑ Back to the top

Article Info
Article ID : 825738
Revision : 8
Created on : 5/18/2007
Published on : 5/18/2007
Exists online : False
Views : 507