Solved

want  to download the DB data to CSV

Posted on 2004-09-20
5
254 Views
Last Modified: 2010-04-03
I want to download a data fetched from an SQL Query to a CSV file.
I am working in ASP. I have also written the code but the problem is that along with the Data the whole HTML page is getting dumped into the CSV file. I want only the DB data and not the whole page. The Page should remain as it is. Please help. I am pasting the code which I have written. The code also forces a save download dialogbox.
Thanks Nilanjan

Code Begins ***************
************************
if operation = "DOWNLOAD" then
            strSQL = "SELECT * FROM GOST_NINSYOU"
            
            if fn_createRecordSet(objRecSet) = false then ' calling function to create recordset
                  Response.Redirect("Error.asp")
            end if
            call fn_rsSQL(objConn,strSQL,objRecSet) ' calling funtion to populate recordset
                  
            For Each F In objRecSet.Fields ' Filling the table field names
              Head = Head & ", " & F.Name
            Next
            Head = Mid(Head,3) & vbCrLf
            Response.Buffer = TRUE
            Response.Clear
            'Response.ContentType = "application/octet-stream"  '****This line give error (Dont know why?????)'
            Response.AddHeader "Content-Disposition", "attachment;filename=" & "test.csv"
            Response.Write Head
            Response.Write objRecSet.GetString(,,", ",vbCrLf,"")
            Response.Expires = 0
            Response.Flush()                  
                        
            call fn_deleteRecordSet(objRecSet) ' calling function to clear recordset
end if
0
Comment
Question by:nilanjan02
5 Comments
 
LVL 2

Expert Comment

by:mingz
ID: 12110094
Maybe you can try other var name beside "Head"..
The page may have taken the html head instead, just a suggestion.
0
 

Author Comment

by:nilanjan02
ID: 12120565
Thanks for the comment, but i have got he solution.
I need to use Response.End() to stop writing into the CSV file
0
 

Accepted Solution

by:
ee_ai_construct earned 0 total points
ID: 12433324
Question answered by asker or dialog valuable.
Closed, 125 points refunded.
ee_ai_construct (replacement part #xm34)
Community Support Admin
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Backup fail due to VSS errors. 4 104
Live Storage Vmotion VMs with shared VMDK 10 52
Dell xps8700 RAID or SAITA 4 37
WD MybookLive Data disappear 6 29
Lets start to have a small explanation what is VAAI(vStorage API for Array Integration ) and what are the benefits using it. VAAI is an API framework in VMware that enable some Storage tasks. It first presented in ESXi 4.1, but only after 5.x sup…
The article will include the best Data Recovery Tools along with their Features, Capabilities, and their Download Links. Hope you’ll enjoy it and will choose the one as required by you.
This tutorial will walk an individual through the process of installing the necessary services and then configuring a Windows Server 2012 system as an iSCSI target. To install the necessary roles, go to Server Manager, and select Add Roles and Featu…
This Micro Tutorial will teach you how to reformat your flash drive. Sometimes your flash drive may have issues carrying files so this will completely restore it to manufacturing settings. Make sure to backup all files before reformatting. This w…

813 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now