When I develop the ASP + Access Web application, I will encounter the problem of locating the path of the database file. When implemented on your own computer, you can specify the event directly. But if you do the project to upload to other servers or mobile other machines to run the use, each time to change the path to change the words appear to be some fan lock, the following combined with my experience to do this site to solve this problem, so that we can "once and for all".
When the Server.MapPath ("file.asp") statement is used in ASP, it returns the absolute path of the file on the local drive, such as "D:\MySite\test\file.asp", So using this statement in different subdirectories will only return the path where the file is located, so we can't simply use this statement to solve the problem above, but it's easy to solve the problem with a little bit of this method and other character functions.
Now let's assume that your site directory structure is as follows:
MySite
|-DB
|-Db1.mdb
|-Db2.mdb
|-Sub_folder
|-hello.asp
|-search.asp
|-index.asp
As long as we add the following statement to the ASP file that requires access to the database:
If session ("RootDir") = "" Then
Dim str
str = Server.MapPath ("db")
Session ("RootDir") = Mid (str, 1, INSTR (1, str, "MySite", 1)-1) & "Mysite\db"
End If
...
Set conn = Server.CreateObject ("Adodb.connection")
Conn. Open "Driver={microsoft Access driver (*.mdb)};d bq=" & Session ("RootDir") & "\db1.mdb" & ";p wd=" & PW
So in the session ("RootDir") stored in your site Neutron directory "db" of the knot path, when you change the home directory of your site or move to another machine in case you can not ignore the database file access path problem.