Solved

Virtual Directories

Posted on 2002-07-11
9
267 Views
Last Modified: 2013-11-18
I have the following database conncetion code that I reference with an INCLUDE file.

<%
        ScriptName = Request.ServerVariables("SCRIPT_NAME")
        ScriptNameParts = Split(ScriptName, "/", -1)
        ScriptName = ScriptNameParts(Ubound(ScriptNameParts))
     
        BaseLoc = Left(Request.ServerVariables("PATH_TRANSLATED"), Len(Request.ServerVariables("PATH_TRANSLATED"))-Len(ScriptName))

     DBase = "databases/supplier.mdb"

        DBasePath = BaseLoc & DBase & ";"
        strProvider="Driver=Microsoft Access Driver (*.mdb); DBQ=" & DBasePath
       
        set objConn = server.createobject("ADODB.Connection")

        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/supplierConnString.asp, line 15

Any ideas ?????????
0
Comment
Question by:WebMaker
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 3

Expert Comment

by:newjack
ID: 7146076
Have you tried a Response.Write of that BaseLoc variable you are compiling?

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...
0
 
LVL 1

Expert Comment

by:pjbaratelli
ID: 7146235
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.mdb
0
 
LVL 18

Expert Comment

by:mgfranz
ID: 7146257
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.Connection")
connAdmin.ConnectionTimeout = 15
connAdmin.CommandTimeout =  10
connAdmin.Open "Provider=Microsoft.Jet.OLEDB.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.OLEDB.4.0;" & "Data Source=" & Replace(Server.MapPath("/database/inventory.mdb"), "html", "")

0
 
LVL 12

Expert Comment

by:Wouter Boevink
ID: 7146846
"Microsoft OLE DB Provider for ODBC Drivers error '80004005' "

It's an permissions error.
0
Network it in WD Red

There's an industry-leading WD Red drive for every compatible NAS system to help fulfill your data storage needs. With drives up to 8TB, WD Red offers a wide array of solutions for customers looking to build the biggest, best-performing NAS storage solution.  

 
LVL 18

Expert Comment

by:mgfranz
ID: 7147063
0
 

Author Comment

by:WebMaker
ID: 7148473
There's nothing wrong with the permissions or the path :

DBasePath = D:\Inetpub\suppliers\databases\supplier.mdb

databases is the virtual directory in which the database supplier.mdb is held.

The real location of databases is :

D:\Inetpub\wwwroot\databases\supplier.mdb

I want the same database to feed both sites.

I'm going slowly mad with this one !!!!!!!!
0
 
LVL 3

Expert Comment

by:newjack
ID: 7148542

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\databases\ and that your server returns D:\Inetpub\suppliers\databases\ very odd.

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\databases instead of D:\Inetpub\wwwroot\databases\

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

0
 

Author Comment

by:WebMaker
ID: 7148625
newjack,

D:\Inetpub\suppliers\databases is a virtual directory created from D:\Inetpub\wwwroot\databases 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 ?
0
 
LVL 3

Accepted Solution

by:
newjack earned 100 total points
ID: 7148807
So I guess all your databases for your webapps are in d:\inetpub\wwwroot\databases.

Why not simply use that path and not bother about the whole virtual directory thing.
It slows down the connection to resolve the path (cause asking for server variables is quite slow) and makes the code harder to read.
I don't think you need a virtual databases directory in your web apps to make the database connections work.

The only reason I see to create such a virtual directory is to be able to download the databases through http, from a browser or something.  (Frankly that's something I wouldn't want to happen in the first place)

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Cloud Backup -- search by date range ? 1 46
cookies analysis tools 2 73
Cordova Camera plugin fails 2 98
What language/protocol is the Angular Chat? 2 58
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
Storage devices are generally used to save the data or sometime transfer the data from one computer system to another system. However, sometimes user accidentally erased their important data from the Storage devices. Users have to know how data reco…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now