Discussion:
Refresh Excel Data ASP
(too old to reply)
MCR
2006-02-08 19:25:49 UTC
Permalink
I'm creating Excel spreadsheets with Response.ContentType =
"application/vnd.ms-excel".

I'm saving selection criteria on session variables to allow users to
dynamically change the content of the spreadsheet using the same asp
page.

My problem is that once it creates the first spreadsheet, when the
parameters are changed, the old report is displayed again. It only
resets when the browser is closed.

Any suggestions?
MCR
2006-02-08 20:52:51 UTC
Permalink
I'll be more specific.

In the example below, the first time I open SELECT.HTM, and select
Blue, REPORT.ASP will use the recordset to create the spreadsheet and
it will return the blue data. If I click on the "Return to Selection
Page" link on the spreadsheet to go back to the SELECT.HTM Page and
select Red, REPORT.ASP will display the Blue Data instead of the Red
data.

How can I make sure that the file is replaced??


<html>
<head>
<title>SELECT.HTM</title>
</head>
<body>
<form action="report.asp" method="post" name="report">
<input type="radio" name="MyOption" value="Blue">Blue<br>
<input type="radio" name="MyOption" value="Red">Red
</form>
</body>
</html>

****************************************************************************************************
****************************************************************************************************

<html>
<head>
<title>REPORT.ASP</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
</head>
<body>
<%
Response.ContentType = "application/vnd.ms-excel"
set cOra = server.createobject("adodb.connection")
set RS = server.createobject("adodb.recordset")
cOra.open "Provider=sqloledb;Data Source=My Data Source;User
ID=MyId;Password=MyPassword"
set RS=cOra.execute("select * from MyTable where " &
request.Form("MyOption"))
%>
<TABLE BORDER=1>
<TR><TD><A HREF="select.htm">Return to Selection Page</A></TD></TR>
<TR>
<%
' %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
' % Loop through Fields Names and print out the Field Names
' %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
For i = 0 to RS.Fields.Count - 1
%>
<TD><B><% = RS(i).Name %></B></TD>
<% Next %>
</TR>
<%
' %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
' % Loop through rows, displaying each field
' %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Do While Not RS.EOF
%>
<TR>
<% For i = 0 to RS.Fields.Count - 1
%>
<TD VALIGN=TOP><% = RS(i).value %></TD>
<% Next %>
</TR>
<%
RS.MoveNext
Loop
RS.Close
set cOra=Nothing
%>
</TABLE>
</body>
</html>

Loading...