Link to home
Start Free TrialLog in
Avatar of danimbrogno
danimbrogno

asked on

File names

sorry, heres another noob question:
and i apologize if i use incorrect terminology.

on my local server ive been using a specific path name to reference my database location (i.e: C:\aspnet\database.mdb)
when i upload my website to the host how would i reference the database if it is in the same directory as the aspx file? i keep getting errors when i try to use like: /database.mdb or \database.mdb or just database.mdb
does it have something to do with server.MapPath ?? thanks a lot

     'set connection
      dim objConn as new OleDbConnection _
      ("Provider=Microsoft.Jet.OLEDB.4.0;" & _
      "Data Source= what goes here?? ")
Avatar of Clif
Clif
Flag of United States of America image

If it is in the same folder as the aspx, then reference it directly (no slashes needed):

 'set connection
      dim objConn as new OleDbConnection _
      ("Provider=Microsoft.Jet.OLEDB.4.0;" & _
      "Data Source= myDatabase.mdb ")

Similarly, if it is in a subfolder of the current webfolder, you can reference it starting from the current aspx folder using backslashes *except* no backslash at the beginning:

 'set connection
      dim objConn as new OleDbConnection _
      ("Provider=Microsoft.Jet.OLEDB.4.0;" & _
      "Data Source= databases\myDayabase.mdb ")

It's when it's outside of your current web folder tree that you get in trouble.
Avatar of danimbrogno
danimbrogno

ASKER

for some reason that doesnt work... but ive solved the problem, i ended up using this code

("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & server.mappath("products.mdb"))

Ill give the points if someone knows why i needed the server.mappath deal... it stumps me
ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial