?
Solved

Saving to a CSV file

Posted on 2001-06-11
3
Medium Priority
?
170 Views
Last Modified: 2013-05-10
I want to be able to save the contents of a ADODB recordset to a csv file. Can someone point me in the right direction.

0
Comment
Question by:Frank
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 43

Accepted Solution

by:
TimCottee earned 200 total points
ID: 6176505
The easiest method is this:
    Open "c:\testbed\Recordset.csv" For Output As #1
    Print #1, rs.GetString(adClipString, -1, ",", vbCrLf, vbNull)
    Close #1

This uses the GetString method of the ADODB.Recordset to format the data into CSV and simply writes it to a file in one go.

There are other methods which provide for more control over formatting but are more complex. If this is what you need then let me know and I can help you with that as well.
0
 

Author Comment

by:Frank
ID: 6176520
Many thanks!
0
 
LVL 1

Expert Comment

by:ShaneCourtrille
ID: 6177961
Actually that wouldn't follow CSV format would it?

CSV formatting requires an item be enclosed in ""'s if it contains any commas for instance.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month11 days, 19 hours left to enroll

752 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