PDA

Click to See Complete Forum and Search --> : Server.MapPath() Error ?


nmretd
Jul 2nd, 2000, 07:13 AM
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
%>

Jul 4th, 2000, 01:19 AM
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:


...
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:

...
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.