Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to save recordset data to Txt/Excel/Access?

Posted on 2000-03-29
2
Medium Priority
?
231 Views
Last Modified: 2008-01-09
In Asp,I want to save the opened recordset data to text file,Excel or Access format.How can I do that?
0
Comment
Question by:huangjian
2 Comments
 
LVL 4

Accepted Solution

by:
ruperts earned 100 total points
ID: 2666399
0
 
LVL 10

Expert Comment

by:makerp
ID: 2666429
you will need to do your query and then open a text file , loop through your resultset and print each filed to the text file in the desired format

i.e

Set Con = Server.CreateObject("ADODB.Connection")

con.Open "your_dsn"

Set rs = Con.Execute("SELECT * FROM mars")


Set fso = CreateObject("Scripting.FileSystemObject")
Set MyFile = fso.CreateTextFile("c:\testfile.txt", True)
 
DO UNTIL rs.EOF
     MyFile.WriteLine(rs("field_one")&","&rs("field_two")&","&rs("field_three"))
    rs.MoveNext
LOOP

MyFile.Close

wrap your fileds in "" for text and use commas to separate fields and you will be able to load it into excel

i.e.


"paul",2,"address",.......
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
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…
Loops Section Overview
Screencast - Getting to Know the Pipeline

885 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