WebMaker
asked on
Virtual Directories
I have the following database conncetion code that I reference with an INCLUDE file.
<%
ScriptName = Request.ServerVariables("S CRIPT_NAME ")
ScriptNameParts = Split(ScriptName, "/", -1)
ScriptName = ScriptNameParts(Ubound(Scr iptNamePar ts))
BaseLoc = Left(Request.ServerVariabl es("PATH_T RANSLATED" ), Len(Request.ServerVariable s("PATH_TR ANSLATED") )-Len(Scri ptName))
DBase = "databases/supplier.mdb"
DBasePath = BaseLoc & DBase & ";"
strProvider="Driver=Micros oft Access Driver (*.mdb); DBQ=" & DBasePath
set objConn = server.createobject("ADODB .Connectio n")
objConn.Open strProvider
%>
It works perfectly in a normal environment, however I've now tried using it in an environment where the folder databases (within the DBase = "databases/supplier.mdb" line) is a virtual directory.
It now gives me the following error :
Microsoft OLE DB Provider for ODBC Drivers error '80004005'
[Microsoft][ODBC Microsoft Access Driver] '(unknown)' is not a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides.
/include/supplierConnStrin g.asp, line 15
Any ideas ?????????
<%
ScriptName = Request.ServerVariables("S
ScriptNameParts = Split(ScriptName, "/", -1)
ScriptName = ScriptNameParts(Ubound(Scr
BaseLoc = Left(Request.ServerVariabl
DBase = "databases/supplier.mdb"
DBasePath = BaseLoc & DBase & ";"
strProvider="Driver=Micros
set objConn = server.createobject("ADODB
objConn.Open strProvider
%>
It works perfectly in a normal environment, however I've now tried using it in an environment where the folder databases (within the DBase = "databases/supplier.mdb" line) is a virtual directory.
It now gives me the following error :
Microsoft OLE DB Provider for ODBC Drivers error '80004005'
[Microsoft][ODBC Microsoft Access Driver] '(unknown)' is not a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides.
/include/supplierConnStrin
Any ideas ?????????
I had a similiar problem. Try this.
strConn = "DBQ=[databasePath];" & _
"Driver={Microsoft Access Driver (*.mdb)};" & _
"FIL=MS Access;"
The database path should be the full path of the database.
ie. F:\databases\myDatabase.md b
strConn = "DBQ=[databasePath];" & _
"Driver={Microsoft Access Driver (*.mdb)};" & _
"FIL=MS Access;"
The database path should be the full path of the database.
ie. F:\databases\myDatabase.md
Well... since I don't use OLE but good ol' ADO, this might not of any use to you. But I suggest a switch to ADO;
Set connAdmin = Server.CreateObject("ADODB .Connectio n")
connAdmin.ConnectionTimeou t = 15
connAdmin.CommandTimeout = 10
connAdmin.Open "Provider=Microsoft.Jet.OL EDB.4.0;" & "Data Source=" & Server.MapPath("/database/ inventory. mdb")
If the directory is in a virtual directory above the MapPath then use this; (html is the name of the Home dir in this case)
connAdmin.Open "Provider=Microsoft.Jet.OL EDB.4.0;" & "Data Source=" & Replace(Server.MapPath("/d atabase/in ventory.md b"), "html", "")
Set connAdmin = Server.CreateObject("ADODB
connAdmin.ConnectionTimeou
connAdmin.CommandTimeout = 10
connAdmin.Open "Provider=Microsoft.Jet.OL
If the directory is in a virtual directory above the MapPath then use this; (html is the name of the Home dir in this case)
connAdmin.Open "Provider=Microsoft.Jet.OL
"Microsoft OLE DB Provider for ODBC Drivers error '80004005' "
It's an permissions error.
It's an permissions error.
ASKER
There's nothing wrong with the permissions or the path :
DBasePath = D:\Inetpub\suppliers\datab ases\suppl ier.mdb
databases is the virtual directory in which the database supplier.mdb is held.
The real location of databases is :
D:\Inetpub\wwwroot\databas es\supplie r.mdb
I want the same database to feed both sites.
I'm going slowly mad with this one !!!!!!!!
DBasePath = D:\Inetpub\suppliers\datab
databases is the virtual directory in which the database supplier.mdb is held.
The real location of databases is :
D:\Inetpub\wwwroot\databas
I want the same database to feed both sites.
I'm going slowly mad with this one !!!!!!!!
the "PATH_TRANSLATED" server variables does a virtual directory to physical directory translation, so in theory your code should work,
are you sure your database is where it should be?
I find the fact that you say your db is in D:\Inetpub\wwwroot\databas
Normally IIS apps are always somewhere in wwwroot, unless you share another folder somewhere on your system, but then you have to make sure your database is also at that location, and not in the wwwroot directory.
So if your webapp is in D:\Inetpub\suppliers\ you need to put your database in D:\Inetpub\suppliers\datab
Also, you migth need to correct the forward slash to a backslash in this line of code,
DBase = "databases/supplier.mdb"
hope this helps,
NJ
ASKER
newjack,
D:\Inetpub\suppliers\datab ases is a virtual directory created from D:\Inetpub\wwwroot\databas es so theoretically the database resides in both of these folders.
Our main web-site is stored in the wwwroot folder, however I want to create another site, separate from the main one (for security reasons) but utilising the same source databases. I thought a virtual directory of the database folder would do the trick.
Also, I've tried changing the forward-slash to a back-slash, but nothing changes.
Any more ideas ?
D:\Inetpub\suppliers\datab
Our main web-site is stored in the wwwroot folder, however I want to create another site, separate from the main one (for security reasons) but utilising the same source databases. I thought a virtual directory of the database folder would do the trick.
Also, I've tried changing the forward-slash to a back-slash, but nothing changes.
Any more ideas ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I'm pretty sure there will be something wrong with that path to your mdb file.
Also, it's not a good thing to put your database in your web-directory (which looks like what you are doing).
Putting it there will allow any user to download it once they know the filename like when directory browsing is enabled...