Microsoft KB Archive/825738

= &quot;System.Data.OleDb.OleDbException&quot; error when you run an ASP.NET Web application =

Article ID: 825738

Article Last Modified on 5/18/2007

-

APPLIES TO


 * Microsoft .NET Framework 1.0
 * Microsoft ASP.NET 1.1
 * Microsoft ASP.NET 1.0
 * Microsoft Access 2000 Standard Edition
 * Microsoft Access 2002 Standard Edition
 * Microsoft Office Access 2003

-



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



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\ \ASPNET\Local settings

where  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 &quot;Symptoms&quot; section.



RESOLUTION
To resolve this problem, enable read/write permissions for the impersonated user account in the Temp folder. To do this, follow these steps:  In Windows Explorer, locate the following folder:

Document settings\ \ASPNET\Local settings\Temp

where  is the name of your server. Right-click the Temp folder, and then click Properties. In the Properties dialog box, click the Security tab. On the Security tab, click Add, and then type \ in the Select Users or Groups text box, where   is the name of your server, and where   is the name of the impersonated account. Click OK . Click to select the Read and the Write check boxes, and then click OK .



STATUS
This behavior is by design.

<div class="moreinformation_section">

Steps to Reproduce the Behavior
 Create a new ASP.NET Web application. To do this, follow these steps:  Start Microsoft Visual Studio .NET.</li> Create a new Microsoft Visual C# .NET or a new Microsoft Visual Basic .NET ASP.NET Web Application. Name the project SampleApplication .</li> Write the code in the SampleApplication file to connect to the Access database.</li></ol> </li> Set the authentication mode to Windows. To do this, follow these steps:  In Solution Explorer, double-click Web.config.</li>  Under the <System.web> section, modify the authentication element as follows: <authentication mode=&quot;Windows&quot; /> </li></ol> </li> Set the impersonation element to true. To do this, follow these steps:   Under the <System.web> section, add the impersonation element as follows: <identity impersonate=&quot;true&quot; /> </li> Save, and then close the Web.config file.</li></ol> </li> On the Build menu, click Build SampleApplication.</li> Set the authentication method on the application. To do this, follow these steps: <ol style="list-style-type: lower-alpha;"> <li>Click Start, and then click Run.</li> <li>In the Open text box, type inetmgr, and then click OK.</li> <li>In the Internet Information Services dialog box, click Default Web Site.</li> <li>Right-click SampleApplication, and then click Properties.</li> <li>In the SampleApplication Properties dialog box, click the Directory Security tab.</li> <li>Under Anonymous access and authentication control, click Edit.</li> <li>In the Authentication Methods dialog box, click to select the Anonymous Access check box. Make sure that the User name text box has the  value, where   is a Windows account. Click OK two times, and then close the Internet Information Services dialog box.</li> <li>Make sure that read/write permissions for  are not enabled in the following folder:

Document settings\ \ASPNET\Local Settings\Temp

</li></ol>

Note IIS uses the following authentication methods to authenticate against the ASP.NET Web application: <ul> <li>Anonymous Authentication: IIS uses the IIS anonymous user account (the default account is IUSR_ ).</li> <li>Integrated Authentication: IIS uses the user account of the user who is currently logged on.</li> <li>Basic Authentication: IIS uses the user-specified account.</li></ul> </li> <li>Run the application. To do this, type http://< >/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 &quot;Symptoms&quot; section.</li></ol>

<div class="references_section">