HOWTO: Server.MapPath to a different server computer

D

Dan Sikorsky

How do you use server.mappath to update a access database on a completely
different computer? One of my websites needs to update a database on a
completely different website.

Example:
My ASP page is on http://www.websiteone.com and I want to update the
database on http://www.websitetwo.com

// where is the Access database?

var sDBPath = Server.MapPath ( 'http://www.websitetwo.com/data/DB.mdb' );



// make up the connection string

var sConnectionString = 'Provider=Microsoft.Jet.OLEDB.4.0; ';

sConnectionString += 'Data Source=' + sDBPath;



When connecting, I get a "An invalid character was specified in the Path
parameter for the MapPath method" error message.
 
G

GJones

Couldn't you use a DTS package in SQL 2000?
-----Original Message-----
How do you use server.mappath to update a access database on a completely
different computer? One of my websites needs to update a database on a
completely different website.

Example:
My ASP page is on http://www.websiteone.com and I want to update the
database on http://www.websitetwo.com

// where is the Access database?

var sDBPath = Server.MapPath
( 'http://www.websitetwo.com/data/DB.mdb' );
// make up the connection string

var sConnectionString
= 'Provider=Microsoft.Jet.OLEDB.4.0; ';
 
T

Tom B

I don't think you can, if that's the only connection you have to the second
database.

I think what I would do, is have my asp page on website one, create
insert/update/delete statements and send them to my asp page on website two.
The page on website two, would then process the queries.

Another option, would be to have website one download the entire access
database locally and use it. Assuming of course that you just want to read
from the database.
 
T

Tom Kaminski [MVP]

Dan Sikorsky said:
How do you use server.mappath to update a access database on a completely
different computer? One of my websites needs to update a database on a
completely different website.

Example:
My ASP page is on http://www.websiteone.com and I want to update the
database on http://www.websitetwo.com

// where is the Access database?

var sDBPath = Server.MapPath ( 'http://www.websitetwo.com/data/DB.mdb' );



// make up the connection string

var sConnectionString = 'Provider=Microsoft.Jet.OLEDB.4.0; ';

sConnectionString += 'Data Source=' + sDBPath;



When connecting, I get a "An invalid character was specified in the Path
parameter for the MapPath method" error message.

You can't. Don't use MapPath at all in this case, use a plain local or UNC
path instead.

var sDBPath = "C:\data\DB.mdb"

OR

var sDBPath = "\\yourserver\data\DB.mdb"
 
J

Jeff Cochran

How do you use server.mappath to update a access database on a completely
different computer?

You can't. Server.Mappath is for the local file system.
One of my websites needs to update a database on a
completely different website.

So? You can't use Server.Mappath, but that doesn't mean you can't use
a UNC path. Although you will run into permission issues and need to
sort those out.
Example:
My ASP page is on http://www.websiteone.com and I want to update the
database on http://www.websitetwo.com

// where is the Access database?

var sDBPath = Server.MapPath ( 'http://www.websitetwo.com/data/DB.mdb' );

Might want to review the Server.Mappath method:

http://www.devguru.com/Technologies/asp/quickref/server_mappath.html
When connecting, I get a "An invalid character was specified in the Path
parameter for the MapPath method" error message.

Yup. That'll happen.

Jeff
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top