Solved

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

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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Suggested Solutions

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…
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

821 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