Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2005
    Posts
    6

    Unanswered: file system object

    Hi Guys,
    I am trying to open an excel sheet on an ASP page using the using the following code given below. but it looks like on some machines the File System object is getting created and on some machines not. On some systems the excel sheet opens and on other it doesn't open, instead it throws a http 500 error. Can you please tell me why this is happening.
    Regards,
    Madhuri

    SET rsQuery = objconn.execute(strSqlQuery1)
    if not rsQuery.EOF then
    set fso = createobject("scripting.filesystemobject")
    ' create the text (xls) file to the server adding the -mmddyyyy after the g_title value
    Set act = fso.CreateTextFile(server.mappath(""&g_filename & "-"& month(date())& day(date())& year(date()) &".xls"), true)

    strLine="" 'Initialize the variable for storing the filednames

    For each x in rsQuery.fields
    strLine= strLine & x.name & chr(9)
    Next

    act.writeline strLine

    Do while Not rsQuery.EOF
    strLine=""
    for each x in rsQuery.Fields
    strLine= strLine & x.value & chr(9)
    next
    act.writeline strLine
    rsQuery.MoveNext
    Loop
    ' close the document

    act.close
    set rsQuery= Nothing

    else
    response.redirect("Sorry.asp")
    end if

  2. #2
    Join Date
    Mar 2004
    Posts
    52
    You could always do like this and let the user save his excelsheet instead, otherwise no clues..

    Code:
    <html>
    <%Response.ContentType = "application/vnd.ms-excel"%>
    <head></head>
    <body>
    <%
    strLine="" 'Initialize the variable for storing the filednames
    
    For each x in rsQuery.fields
    strLine= strLine & x.name & chr(9)
    Next
    
    Do while Not rsQuery.EOF
    strLine=""
    for each x in rsQuery.Fields
    strLine= strLine & x.value & chr(9)
    next
    response.write strLine
    rsQuery.MoveNext
    Loop
    ' close the document 
    
    set rsQuery= Nothing
    
    <%>
    </body>
    </html>
    "Never underestimate a large number of morons"

Posting Permissions

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