View Full Version : Connection String Problem

01-19-2007, 05:39 AM
The '..' characters are not allowed in the Path parameter for the MapPath method.
/Connections/connportal.asp, line 30

This is line 30
MM_connDUportal_STRING = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("..\_private\portal.mdb")

01-19-2007, 01:21 PM
It's usually more helpful if you keep related issues in the same thread (http://www.codingforums.com/showthread.php?t=105413).

You can't mappath a dir outside the server root. The server doesn't know that there are dirs outside its root path.

What you can do is mappath the server root:

serverRoot = server.mappath("/")

and use that to manually construct the path you need, since you know where your _private dir is in relation to the root.

01-23-2007, 02:56 PM
You need to allow parent paths in IIS.

If you cannot do this then you can create a path using the server-variables

p_path = Request.ServerVariables("APPL_PHYSICAL_PATH")
' c:\domains\d\domain.com\user\htdocs\

' Using Split
path = Cstr(p_path)
path = Split(p_path,"\")

For section=0 To Ubound(Path)-2
root = root & Path(section) & "\"
' c:\domains\d\domain.com\user\

' Using string functions
root = Mid(p_path,1,InStrRev(p_path,"\",InStrRev(p_path,"\")-1))
' c:\domains\d\domain.com\user\

db = root & database
' c:\domains\d\domain.com\user\data\pw.mdb