Results 1 to 2 of 2

Thread: Server.MapPath()

  1. #1
    Join Date
    Dec 1969

    Default Server.MapPath()

    Possibly the most annoying error to have. I have a website that has 3 directories; Private, HTML and Logs. The private file is for my database, and the HTML for my asp scripts. However I can&#039;t seem to call up the database from my ASP pages. I know the MapPath, but how do I call the Private directory From Inside the HTML directory, it seems to look directly from the HTML directory. I unserstand that it is a difficult question to answer, as I am not giving you my server information, but any suggestions why it will not retrieve my database, here is what I am using:<BR><BR><BR>Set Con = Server.CreateObject("ADODB.Connection")<BR>Con.Ope n "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("Businessmyaccountprivatemydatabase .mdb")<BR><BR>Thank You<BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default Bill's mantra: DEBUG DEBUG DEBUG

    First, you have to be sure that Server.MapPath is actually giving you the right directory!<BR><BR>SO:<BR><BR>&#060;%<BR>dbpath = Server.MapPath("Businessmyaccountprivatemydatabase .mdb")<BR>Response.Write "Trying to open database at absolute location: " & dbpath & "&#060;HR&#062;"<BR><BR>Set Con = Server.CreateObject("ADODB.Connection")<BR>Con.Ope n "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & dbpath<BR>%&#062;<BR><BR>Server.MapPath is most effectively used via relative addressing. So if your structure is<BR><BR>Business<BR>&nbsp; &nbsp; myaccount<BR>&nbsp; &nbsp; &nbsp; &nbsp; private<BR>&nbsp; &nbsp; &nbsp; &nbsp; HTML<BR>&nbsp; &nbsp; &nbsp; &nbsp; Logs<BR>&nbsp; &nbsp; anotheraccount<BR><BR>and if you are executing a script that resides in the HTML directory, you might find that <BR>&nbsp; &nbsp; Server.MapPath("..privatemydatabase.mdb") <BR>works best. <BR><BR>When you put a (or / ... server.mappath treats both identically) at the front of the path to be mapped, you are asking to start at the root of the server. And you *might* not be right about what the server thinks the root is.<BR><BR>Anyway, see what the debug output shows you. If the absolute path returned by Server.MapPath is off...well, then all bets are off, aren&#039;t they?<BR><BR><BR><BR><BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts