Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


ASP output to CSV file

Posted on 2003-10-21
Medium Priority
Last Modified: 2010-03-25
I have an ASP page that returns the results from a database search.  It used to work but I noticed recently that the CSV file now displays the html code from the ASP page rather than the results from the search.  Any suggestions on how to correct this problem?  I checked to make sure the IIS 4.0 App Mappings associates the .csv file with asp.dll and it does.  Thanks for your help!

This is the code I'm using:

<%Response.AddHeader "Content-Disposition", "filename=filename.csv;"%>

<meta HTTP-EQUIV="Content-Type" CONTENT="text/html;charset=windows-1252">
<title>Search Results</title>


    Set conn = Server.CreateObject("ADODB.Connection") "MyConnection","",""
 sql = "SELECT * FROM Table1"

Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open sql, conn ', 3, 3

    <% Do while Not RS.EOF %>
     <TD VALIGN=TOP><% = RS("Field1") %>&nbsp;</TD>  
    <TD VALIGN=TOP><% = RS("Field2") %>&nbsp;</TD>
 <%   RS.MoveNext
      Loop   %>

set rs=nothing
set conn=nothing


Question by:drees727
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment

Accepted Solution

sicknote earned 500 total points
ID: 9593407
try this:


Response.AddHeader "Content-Disposition", "filename=filename.csv;"

Set conn = Server.CreateObject("ADODB.Connection") "MyConnection","",""

sql = "SELECT * FROM Table1"

Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open sql, conn ', 3, 3

Do while Not RS.EOF

set rs=nothing
set conn=nothing

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: and…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question