Server.Mappath

Of course, with Classic ASP, it was possible to ‘emulate’ the exact path of the MS Access Database in the connection string by using ‘Server.Mappath’.

In ASP.Net, it can still be used, however, you won’t be able to use ‘..\’ to go up a directory from the root, like was possible with Classic ASP – directly. To do that, there are two different ways to accomplish this. One way is – create a virtual directory pointing to that directory and reference it accordingly inside your ASP.Net page. The second way is by doing it this way:

MyConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.mappath("/") & "../data/myDB.mdb;"

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>