Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   ASP Page not opening a new Excel Spreadsheet each time. (http://www.velocityreviews.com/forums/t116680-asp-page-not-opening-a-new-excel-spreadsheet-each-time.html)

lds 01-04-2006 07:12 PM

ASP Page not opening a new Excel Spreadsheet each time.
 
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>



All times are GMT. The time now is 02:00 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.