Click here to Skip to main content
15,886,763 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
Hi,

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

XML
<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

1 solution

Not sure if i got your problem correctly but what i've understand is that you are encounterring the error when in asp.net. If yes, why not try to include that file in your asp.net 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.
 
Share this answer
 
Comments
Shemeer NS 7-Jul-12 11:39am    
that file is included in the App_Data folder of asp.net 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900