Solved

Server MapPath with direct address

Posted on 2002-05-09
9
476 Views
Last Modified: 2011-08-18
   Having a problem connecting to an access database on a second server with that server's direct address.

Set objDC = Server.CreateObject("ADODB.Connection")
objDC.Open "DBQ=" & Server.MapPath("\\Server2\ServerDBs\TestDB.mdb") & _
 ";Driver={Microsoft Access Driver (*.mdb)}"
           
 
    The ASP program is running on Server1 and gives the following error

Server.MapPath() error 'ASP 0174 : 80004005'
Invalid Path Character(s)
An invalid '/' or '\' was found in the Path parameter for the MapPath method.

    How can I connect to \\Server2's database.


 
0
Comment
Question by:JerryPope
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 5

Accepted Solution

by:
dgorin earned 150 total points
ID: 7000589
First, MapPath converts a url to a physical path.  You are already dealing with a physical path, just on a different computer.

There are many pitfalls with connecting to an access db on a separate machine, mostly permission related.  Your web server usually runs in a local user account on the server, so you need to create an identical user on the 2nd computer with the database and give it appropriate permissions.  You can find more on this subject on the Microsoft website.
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 7001360
The easiest way to do this is to map the drive containing the database to the server hosting the site. That way, you avoid a whole series of complications with paths and permissions.

Fritz the Blank
0
 

Expert Comment

by:jerry2yu
ID: 7001522
Hi JerryPope,

Try to replace \ with \\

That will be

Set objDC = Server.CreateObject("ADODB.Connection")
objDC.Open "DBQ=" & Server.MapPath("\\\\Server2\\ServerDBs\\TestDB.mdb") & _
";Driver={Microsoft Access Driver (*.mdb)}"
           

   
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 7001586
I could be wrong, but I am reasonably sure that Jerry2U's solution won't work because of permsissions issues. In order for the connection to function, the IUSR and IWAM accounts of the machine hosting the site should have Read/Write priviledges to the directory holding the database. If you map the drive, that will be easy enough. If you follow Jerry2U's approach, you will need to duplicate the IUSR and IWAM accounts with the proper machine name and etc. on the second server. While this is possible, it is not for the faint of heart.

Fritz the Blank
0
 
LVL 18

Expert Comment

by:mgfranz
ID: 7001679
In order to connect a IUSER_ to a remote server, the account needs to be duplicated on the remote server, read here for all the details;

http://support.microsoft.com/default.aspx?scid=kb;EN-US;q184566
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 7001696
Marki,

What's your take on mapping the drive versus duplicating the IUSR account?

Fritz the Blank
0
 
LVL 18

Expert Comment

by:mgfranz
ID: 7001706
Even if you map the drive, the remote server will not recognize the IUSER_ account, something to do with ACL's or something...
0
 
LVL 5

Expert Comment

by:dgorin
ID: 7001729
All of which is what I said.


0
 

Author Comment

by:JerryPope
ID: 7003462
Hello dgorin

    Your statement about MapPath converts to a physical path lead me to the below solution.

objDC.Open "DBQ=\\Server2\ServerDBs\TestDB.mdb;"

   Thank you,
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
JSON error 4 70
Display first 3 lines of text from database field, vbscript asp 4 58
Microsoft SQL ADO Conn Issue 6 50
JQuery Autocomplete Tag AJAX (Need nice script) 11 34
I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …

790 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