Home > DeveloperSection > Forums > Server.MapPath in ASP.Net
Mark Devid
Mark Devid

Total Post:101

Points:707
Posted on    August-25-2014 2:06 AM

 ASP.Net ASP.Net 
Ratings:


 1 Reply(s)
 766  View(s)
Rate this:

I have developed a Web Application using ASP.Net with Microsoft Access as database. Now i have connected to the database using OleDB connection. The problem is when i give the database source in Connection String Source="C:/WebApp/DB/data.mdb". The connection throws an error stating the path is invalid and there is no such file.

I tried using

Server.MapPath("~/DB/data.mdb")

which gives the path as "C:/WebApp/DB/data.mdb" but throws the same error

Colud not locate file 'C:/WebApp/DB/data.mdb'

What should be the problem, even though if it works good in loalhost when i publish it to the server using Plesk, it shows the same error stating "C:/inetpub/xyx.com/httpdocs/..." not found



Sumit Kesarwani

Total Post:378

Points:2694
Posted on    August-25-2014 2:29 AM

Hi Mark, 

There might have several problems, would you please check below items:

Check the DB folder is exists at root level of your application

Make sure the database file data.mdb is exist uder DB folder

Take appropriate action based on any option is missing as listed above.


Don't want to miss updates? Please click the below button!

Follow MindStick