Sign in to follow this  
Nahoopii

[web] Export Query Results to downloadable .CSV

Recommended Posts

Hey geniuses, Im working on an ASP.net page, where (hopefully) a user can click a button/link, which will execute the query and save the results to a downloadable .CSV file, or directly to their PC. Is there an easy way for this to be done? It sounds like a pretty common-place task and being the inexperienced web developer that I am, I thought I would ask if anyone new how to go about this quickly and easily. If youd rather not go into it, but do know of some good online resources to visit, I would be just as obliged! Thanks in advance

Share this post


Link to post
Share on other sites
For anyone keeping score, Ive figured it out:
A nice explanation from the ever trusty W3schools

The answer lies within using a FileSystemObject;

After setting and opening the Oracle DB connection string, I loaded the data into a recordset (update) and looped through printing the query results:

Set Update=Conn.Execute(sqlText)

Set fs=Server.CreateObject("Scripting.FileSystemObject" )

set tfile = fs.CreateTextFile(Server.MapPath("Market_Extract.csv"))
Update.movefirst

Do Until Update.EOF
tfile.WriteLine (Update("NPA" ) & " ," & Update("NXX" ))
Update.movenext
Loop


Hope this helps someone has to do this same task. Good luck!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this