HOWTO: Server.MapPath to a different server computer

Discussion in 'ASP General' started by Dan Sikorsky, Nov 20, 2003.

  1. Dan Sikorsky

    Dan Sikorsky Guest

    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.


    --
    Dan Sikorsky, MSCS BSCE BAB
     
    Dan Sikorsky, Nov 20, 2003
    #1
    1. Advertising

  2. Dan Sikorsky

    GJones Guest

    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; ';
    >
    >sConnectionString += 'Data Source=' + sDBPath;
    >
    >
    >
    >When connecting, I get a "An invalid character was

    specified in the Path
    >parameter for the MapPath method" error message.
    >
    >
    >--
    >Dan Sikorsky, MSCS BSCE BAB
    >
    >
    >
    >.
    >
     
    GJones, Nov 20, 2003
    #2
    1. Advertising

  3. Dan Sikorsky

    Tom B Guest

    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.



    "Dan Sikorsky" <> wrote in message
    news:...
    > 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.
    >
    >
    > --
    > Dan Sikorsky, MSCS BSCE BAB
    >
    >
    >
     
    Tom B, Nov 20, 2003
    #3
  4. Dan Sikorsky

    Tom B Guest

    The o/p said they were using Access.

    "GJones" <> wrote in message
    news:077201c3af00$5595fe60$...
    > 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; ';
    > >
    > >sConnectionString += 'Data Source=' + sDBPath;
    > >
    > >
    > >
    > >When connecting, I get a "An invalid character was

    > specified in the Path
    > >parameter for the MapPath method" error message.
    > >
    > >
    > >--
    > >Dan Sikorsky, MSCS BSCE BAB
    > >
    > >
    > >
    > >.
    > >
     
    Tom B, Nov 20, 2003
    #4
  5. Dan Sikorsky

    Dan Sikorsky Guest

    I think you're right. I'll have to restructure my logic.

    --
    Dan Sikorsky, MSCS BSCE BAB


    "Tom B" <> wrote in message
    news:...
    > 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.
    >
    >
    >
    > "Dan Sikorsky" <> wrote in message
    > news:...
    > > 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.
    > >
    > >
    > > --
    > > Dan Sikorsky, MSCS BSCE BAB
    > >
    > >
    > >

    >
    >
     
    Dan Sikorsky, Nov 20, 2003
    #5
  6. "Dan Sikorsky" <> wrote in message
    news:...
    > 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"

    --
    Tom Kaminski IIS MVP
    http://www.iistoolshed.com/ - tools, scripts, and utilities for running IIS
    http://mvp.support.microsoft.com/
    http://www.microsoft.com/windowsserver2003/community/centers/iis/
     
    Tom Kaminski [MVP], Nov 20, 2003
    #6
  7. Dan Sikorsky

    Jeff Cochran Guest

    On Wed, 19 Nov 2003 19:11:31 -0500, "Dan Sikorsky" <>
    wrote:

    >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
     
    Jeff Cochran, Nov 20, 2003
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jon
    Replies:
    5
    Views:
    11,269
    Scott M.
    Jan 17, 2010
  2. Peter Row
    Replies:
    0
    Views:
    451
    Peter Row
    Feb 23, 2004
  3. =?Utf-8?B?dHBhcmtzNjk=?=

    server.mappath vs. request.mappath

    =?Utf-8?B?dHBhcmtzNjk=?=, Mar 10, 2007, in forum: ASP .Net
    Replies:
    2
    Views:
    1,185
    Juan T. Llibre
    Mar 11, 2007
  4. Replies:
    4
    Views:
    996
    Juan T. Llibre
    Oct 7, 2007
  5. Peng Jie
    Replies:
    6
    Views:
    146
    Peng Jie
    Feb 6, 2005
Loading...

Share This Page