Results 1 to 9 of 9

Thread: asp directory

  1. #1
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    asp directory

    I am scratching my head here and I can't quite get the connection string right <img src=/S/scratch.gif border=0 alt=scratch width=25 height=29>

    I have an excel workbook containing some columns of data and want them displayed on an asp page. This works perfectly well on my local host but I am fiddling about trying to view it on my website. The excel workbook and the asp page reside in a folder called in excel (OK it is in test mode at the moment <img src=/S/grin.gif border=0 alt=grin width=15 height=15>.

    The code is:
    ...

    Set oConn = Server.CreateObject("ADODB.connection")
    oConn.Open "Driver={Microsoft Excel Driver (*.xls)}; DriverId=790;" &_
    "DBQ=c:Inetpubwwwrootexcelexcel.xls;" &_
    "DefaultDir = C:Inetpubwwwrootexcel"
    ...

    what is the correct syntax for DBQ and DefaultDir?
    Jerry

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: asp directory

    If they're in the same folder, you should probably use

    Set oConn = Server.CreateObject("ADODB.connection")
    oConn.Open "Driver={Microsoft Excel Driver (*.xls)}; DriverId=790;" & _
    "DBQ=/excel.xls;"

    I'd omit the DefaultDir argument. And you need spaces between the & and _.

  3. #3
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: asp directory

    Thanks Hans

    I have tried this and I seem to be getting a similar error message via my web site, I have even tried absolute references, like so:

    Set oConn = Server.CreateObject("ADODB.connection")
    oConn.Open "Driver={Microsoft Excel Driver (*.xls)}; DriverId=790;" &_

    "DBQ= http://www.magicforest.co.uk/excel/excel.xls;" &_
    "DefaultDir = http://www.magicforest.co.uk/excel/"

    but get this:

    http://support.microsoft.com/kb/190006/ defining a ODBC Drivers error '80004005'


    Maddening as I think it is out of my hands
    Jerry

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: asp directory

    I should have known better than to stray outside my field. Sorry! <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

  5. #5
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: asp directory

    <img src=/S/laugh.gif border=0 alt=laugh width=15 height=15>

    It made sense though <img src=/S/thumbup.gif border=0 alt=thumbup width=15 height=15>

    Researching this though it appears that it may be my account and the read write permissions i have on the web service.

    You maybe able to help though as I seem to remember about driver ID's for excel, this one is currently set at 790 , is there one for Excel 2003?
    Jerry

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: asp directory

    DriverID = 790 is valid for all versions of Excel from 97 to 2003, and also for Excel 2007 as long as you use the old .xls format. They share the same file format. I don't know if there is a version for the new .xlsx format in Excel 2007.

  7. #7
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: asp directory

    It's OK Jezza

    It appears that my host has to think about service packing their server <img src=/S/drop.gif border=0 alt=drop width=23 height=23>
    Jerry

  8. #8
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: asp directory

    Hi Jezza

    I know this is an old message but I thought I would just post the solution as it was on the back burner.

    The difficulty we have when developing on our local PCs and in IIS is we create absolute links to a specific folder on our PC, something that is not mirrored on the server. So we replace the have to write the DBQ path using Server.Path like so:


    'strDriver = "Driver={Microsoft Excel Driver (*.xls)};DBQ=excel.xls;"
    Set oConn = Server.CreateObject("ADODB.Connection")
    objConn.Open "DBQ=" & Server.MapPath("excel.xls") & ";" & "DRIVER={Microsoft Excel Driver (*.xls)};"
    'oConn.Open strDriver

    This code makes the following assumptions

    1) The file is called excel.xls
    2) Both the asp file and the excel file are in the same root folder (for this example)
    3) You Host allows Read access
    Jerry

  9. #9
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: asp directory

    Here's a random thought: it's handy to use the global.asa file for connect strings and paths. Then there are fewer .asp files to change if the database moves or is renamed, etc.

Posting Permissions

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