Click here to Skip to main content
13,149,186 members (56,105 online)
Rate this:
Please Sign up or sign in to vote.

I'm trying to connect MS Access (*.mdb file) from ASP.NET, Everything Works fine in windows application in my PC. the same code giving error in ASP.NET

In ASP.NET Oledb connection is success but while reading from datatreader its giving a strange error :(, Any idea on this issue? Pls help, Thanks In advance

the code is as follows

Connection string is

<add name="oledbCon" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\mydatabase.mdb" providerName="System.Data.OleDb"/>

Everything works fine in windows application the same code in ASP.NET throws error from the below line
reader = cmd.ExecuteReader();

Error is

Could not find file 'C:\Program Files (x86)\Common Files\Microsoft Shared\DevServer\10.0\dbo.mdb'

where as in my connection string I can see the my datasource as D:\mydatabase.mdb from debug window

Steps I tried is given below

changed the from AnyCPU to x86 in VS 2010 configuration

Pls not : MS Access is 32 bit and Windows 7 64 bit, and VS 2010 configuration changed to x86, When I'm getting this error I checked the connection state in quickwatch and its in Open state.
Posted 7-Jul-12 3:09am
Shemeer NS124.3K

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Not sure if i got your problem correctly but what i've understand is that you are encounterring the error when in If yes, why not try to include that file in your project just like the images or misc files and from there youll just map it.

Its working on windows app because youre just in your computer not a host.
Shemeer NS 7-Jul-12 11:39am
that file is included in the App_Data folder of and correspondingly I have changed the path in web.config also.... then also it was giving same error...
seravan 9-Jul-12 0:47am
Based from the connection string it's pointing to D drive while on you error it's pointing on the C drive and also a different MS Access file.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.170924.2 | Last Updated 7 Jul 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100