ASP Page not opening a new Excel Spreadsheet each time.

Discussion in 'ASP .Net' started by lds, Jan 4, 2006.

  1. lds

    lds Guest

    I have inhertited and old asp application that I have to make a few
    changes to and I am having difficulties with a page that retrives data
    from the database, and places it into an Excel spreadsheet. It seemed
    to be working fine in the beginning, but not anymore. The only thing
    that I know of that could be different is that I installed J2SE Runtime
    Environment 5.0 Update 6. I have since uninstalled it just to see if
    it makes any difference, which it did not.

    How the page works, is that the user selects different fields to be
    displayed as well as the criteria for the query. A select statement is
    created and executed against the database. The page then loops though
    the records returned creating a table. The Response.ContentType =
    "application/vnd.ms-excel"

    Sometimes it works the first time, but then if you go back, change the
    selection criteria and/or fields to be displayed and submit the form
    again, you get the same results as the last query. I have checked to
    make sure that the query itself changes and it does.

    Here is a sample of the code being used:

    Set rs0 = Server.CreateObject("ADODB.Recordset")
    rs0.open strsql, cn
    If not rs0.BOF and not rs0.EOF then
    Response.Clear
    Response.Buffer = True
    Response.ContentType = "application/vnd.ms-excel"
    rs0.MoveFirst%>
    <HTML>
    <HEAD>
    <META HTTP-EQUIV="no-cache">
    </HEAD>
    <BODY>
    <p>&nbsp;
    <table border=0 cols=<%=rs0.Fields.Count%> ID="Table1">
    <tr>
    <%for each oField in rs0.Fields%>
    <th><%=oField.name%></th>
    <%next%>
    </tr>
    <%do while not rs0.EOF %>
    <tr>
    <%for each oField in rs0.Fields%>
    <td align=left>
    <%if IsNull(oField) then
    Response.Write "&nbsp;"
    else
    Response.Write (oField.Value)
    end if%>
    </td>
    <%next
    rs0.MoveNext
    %>
    </tr>
    <%loop%>
    </table>
    <%end if%>
    </BODY>
    </HTML>
     
    lds, Jan 4, 2006
    #1
    1. Advertising

  2. lds

    lds Guest

    I just thought that I would add that this has started working for me
    again. The only thing I did was delete my recent documents and files
    in my temp directory. I guess I just need to figure out why there was
    a copy there to begin with...
     
    lds, Jan 4, 2006
    #2
    1. Advertising

  3. lds

    lds Guest

    I just thought that I would add that this has started working for me
    again. The only thing I did was delete my recent documents and files
    in my temp directory. I guess I just need to figure out why there was
    a copy there to begin with...
     
    lds, Jan 4, 2006
    #3
    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. =?Utf-8?B?S2VpdGhSYWdpbkZAbmV3c2dyb3Vwcy5ub3NwYW0=

    Returning Excel Spreadsheet as web page

    =?Utf-8?B?S2VpdGhSYWdpbkZAbmV3c2dyb3Vwcy5ub3NwYW0=, Apr 23, 2004, in forum: ASP .Net
    Replies:
    10
    Views:
    2,767
    Steven Cheng[MSFT]
    May 6, 2004
  2. lds
    Replies:
    0
    Views:
    456
  3. Robert Smith

    opening up an excel spreadsheet in asp.net

    Robert Smith, Apr 23, 2008, in forum: ASP .Net
    Replies:
    1
    Views:
    986
    Ross Culver
    Apr 23, 2008
  4. Horhayson

    Displaying an Excel spreadsheet in ASP page?

    Horhayson, Feb 2, 2005, in forum: ASP General
    Replies:
    3
    Views:
    153
    Tom Kaminski [MVP]
    Feb 2, 2005
  5. fniles
    Replies:
    0
    Views:
    288
    fniles
    Apr 26, 2009
Loading...

Share This Page