|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I am trying to understand the Server.MapPath method and would appreciate an explanation of why this works:
I have a file on a remote ISP [\webroot\myfile.asp] that has the following in it: ‘Open the Database Connection %><!--#INCLUDE file=”connect.inc”<% [Note: the connect file is also located within the webroot directory] My database, storeDB.mdb, is located in a database folder within the root directory on the same level as the webroot folder (not within the webroot folder). Therefore, the connect.inc. is as follows: <% '*** Open the Connection '*** NOTE: MS Access-specific dsn-less connection here! IF IsObject(Session("goConn")) THEN SET Conn=Session("goConn") ELSE lcConnect = "DRIVER={Microsoft Access Driver (*.mdb)};" lcConnect = lcConnect & "DBQ=" & Server.MapPath("../database/storeDB.mdb") Set Conn = Server.CreateObject("ADODB.Connection") Conn.Open lcConnect Set Session("goConn")=Conn END IF %> All of the above successfully makes a connection to my database and everything works fine. However, I am having a devil of a time getting a connection when I do the following: I want to put connect.inc within a folder within the webroot. The path would be [\webroot\includes\connect.inc ]. I also would like to move myfile.asp into a folder within the webroot. The path would be [ \webroot\services\myfile.asp ]. With these relocations, why doesn’t these additional changes to the relocated files work: In \webroot\services\myfile.asp: ‘Open the Database Connection %><!--#INCLUDE file=”../includes/connect.inc”<% I have tried both Server.MapPath("../database/storeDB.mdb") as well as Server.MapPath(“database/storeDB.mdb) or Server.MapPath(“/database/storeDB.mdb) and none of these make a proper connection. I’m sure this is a file path issue and a misunderstanding of the Server.MapPath method. Could someone help me with the proper file paths and clear up my muddled understanding? I would sincerely appreciate it. |
|
#2
|
|||
|
|||
|
a path issue? have a look at this: (as long as you just didnt misprint in this tread..)
Code:
‘Open the Database Connection %><!--#INCLUDE file=”../includes/connect.inc”<% try to change it to: Code:
‘Open the Database Connection %><!--#INCLUDE file=”../includes/connect.inc”--><% because the #include tag wasnt closed, im not sure if its neccessary, but i thinks so. |
|
#3
|
|||
|
|||
|
i do not understand why does your connect.inc works well, because when i use it, the mistake occurs:
Server.MapPath() error 'ASP 0175 : 80004005' Disallowed Path Characters /connect.asp, line 3 The '..' characters are not allowed in the Path parameter for the MapPath method. |
![]() |
| Viewing: ASP Free Forums > Other > Programming Help > Request help understanding Server.MapPath connection issue |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|