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

Posted on 2000-03-29
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?
Question by:huangjian

Accepted Solution

ruperts earned 25 total points
ID: 2666399
LVL 10

Expert Comment

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


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)


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



Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Select distinct 25 83
Voice recognition ASP or ASP.NET or JavaScript 2 60
ASP Button to clear text 4 44
CDO.Message not able to send attachement 5 14
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…
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…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

867 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

17 Experts available now in Live!

Get 1:1 Help Now