Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2006
    Posts
    72

    Unanswered: Changing server.MapPath to "driver, etc"

    Hello

    I often see connection strings to MS Access databases written in this format:

    Code:
    'Build connection
    	set conn = server.CreateObject ("ADODB.Connection")
    	conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.MapPath ("users.mdb")
    	set rs = server.CreateObject ("ADODB.Recordset")
    Unfortunately, it's one which my hosting services does not like, preferring instead this format:

    Code:
    conn.Open "driver={Microsoft Access Driver (*.mdb)};DBQ=D:\business\users.mdb;"
    How is it best (or easiest) to translate the first type of connection to the second?

    Can I simply change:

    Code:
    conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.MapPath ("users.mdb")
    to:

    Code:
    conn.Open "driver={Microsoft Access Driver (*.mdb)};DBQ=D:\business\users.mdb;"
    Thanks for any advice.

    Steve

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Hey Steve,
    Quote Originally Posted by Quetzal
    Can I simply change:
    to:
    I don't see why not! Think of the connection string as a way of telling your front-end where to look for it's data and if necessary how to authenticate to retrieve any data.

    A good test would be to simply write teh value from your Server.MapPath to screen and see what is returned!

    Merry Christmas
    George
    Home | Blog

  3. #3
    Join Date
    Feb 2006
    Posts
    72
    Many thanks for your reply, George.

    I'll try it out!

    Merry Christmas to you, too!

    Steve

  4. #4
    Join Date
    Sep 2006
    Posts
    265
    Anyone who uses FSO uses server.mappath. As includes can not be dynamic FSO is the only means of "attaching" content in a file depending on the content on the page.

    You could try:

    Application("my_conn") = "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE= [the physical path and Users.mdb]

    Simon

Posting Permissions

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