Jump to content
  • Advertisement
Sign in to follow this  
Nahoopii

[web] Export Query Results to downloadable .CSV

This topic is 4820 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!