Results 1 to 2 of 2

Thread: Server.MapPath() Error ?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 1999
    Location
    London, England
    Posts
    213
    I am getting the following error, can someone explain how I can fix this please ?

    Server.MapPath() error 'ASP 0172 : 80004005'

    Invalid Path

    The Path parameter for the MapPath method must be a virtual path. A physical path was used.

    I am using the following code to connect to the Database:

    <%@ LANGUAGE="VBSCRIPT" %>
    <% Option Explicit %>
    <%
    Dim DATA_PATH, objDC, objRS, email, user, pass, sendmail
    DATA_PATH=Server.Mappath("c:/InetPub/wwwroot/userlogon/MyData.mdb")
    Set objDC = Server.CreateObject("ADODB.Connection")
    objDC.ConnectionTimeout = 15
    objDC.CommandTimeout = 30
    objDC.Open "DBQ=" & DATA_PATH & _
    ";Driver={Microsoft Access Driver (*.mdb)}; " & _
    "DriverId=25;MaxBufferSize=8192;Threads=20;", _
    "admin", "password"
    Set objRS = Server.CreateObject("ADODB.Recordset")
    email=request.form("email")

    objRS.Open "SELECT * FROM tblUSR WHERE name = '" & _
    name & "'", objDC, 0, 1
    %>


  2. #2
    Guest
    Server.MapPath is used to convert relative paths to absolute paths. So let's say that c:\inetpub\wwwroot\ is your root directory and you have a subdirectory called userlogon which contains the database MyData.mdb. What you can do is the following:

    Code:
    ...
    DATA_PATH = Server.MapPath ("userlogon/MyData.mdb")
    ...
    that should work because it's a relative(or virtual if you may) path and not a physical(or absolute) path(i.e. c:\inetpub\wwwroot\userlogon\MyData.mdb) Make sense? Here's a debugging tip: use the following to debug the results of your call to Server.MapPath:
    Code:
    ...
    DATA_PATH = Server.MapPath ("userlogon/MyData.mdb")
    Response.Write "DATA_PATH =" & DATA_PATH
    Response.End
    ...
    that way you get to see what MapPath is generating; and obviously in your case it would be an error but in the case that you gave an incorrect virtual path it helps in finding that out quickly and with fewer headaches.

Posting Permissions

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



Click Here to Expand Forum to Full Width