Solved

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

Posted on 2000-03-29
2
221 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 25 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

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…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

708 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