Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Jan 2006
    Posts
    54
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation complete ASP newb: want to set correct absolute path

    hi all

    first off, i know absolutely nothing at all about ASP; i use PHP a little, but I'm mostly a Flash programmer. I've just had to take over a client's site in an emergency and move it across to a new server. the problem is, a particular feature of the site was done in ASP, and an included connection file points to the absolute path of the .mdb database, but obviously with the site being on a new host the path no longer exists:

    MM_sos_STRING = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=e:\domains\s\site.com\user\htdocs\MapData.mdb"

    i checked with the new host, and their faqs state that i should simply use:

    Server.MapPath("")

    however, the new host also talks about setting up a file DSN to properly enable access and... well, at this point I'm completely lost. will i have to recode most of the connection data to establish a connection to the file DSN, or can the original file simply be modified?

    please, please help!
    you are invited | http://www.indextwo.net

  • #2
    Regular Coder
    Join Date
    Mar 2007
    Posts
    505
    Thanks
    1
    Thanked 19 Times in 19 Posts
    For Absolute Paths, you will want to use

    Server.MapPath("folder/to/location/file.mdb")

    Server.MapPath uses the absolute root of your directory, so you can use either
    Server.MapPath("/domains/s/site.com/user/htdocs/MapData.mdb")
    or
    Server.Mappath("<drive>:/domains/s/site.com/user/htdocs/MapData.mdb").

    Both should work.

    To set up a DSN, you have to have access to the server that the databases is hosted on. Then, use either Control Panel or Administrative Tools to get to ODBC Data Sources. Follow the prompts to create a new DSN to your .MDB file.

    In your code, instead of Server.MapPath, you will want to use:

    Set conn = Server.CreateObject("ADODB.Connection")
    conn.open "DSN=<dsnname>"

    That's it.

    HTH!

  • #3
    SSJ
    SSJ is offline
    Regular Coder
    Join Date
    Mar 2007
    Posts
    230
    Thanks
    0
    Thanked 4 Times in 4 Posts
    MM_sos_STRING = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath("MapData.mdb")
    Try this and let me know if it is okay

  • #4
    New Coder
    Join Date
    Jan 2006
    Posts
    54
    Thanks
    0
    Thanked 0 Times in 0 Posts
    wow - that did work! thanks for that.

    ...although it's been so utterly painful, i actually decided it would be easier for me to create a new database in MySQL and script a custom CMS in php rather than go through that particular rigmarole again!
    you are invited | http://www.indextwo.net


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •