Solved

Saving to a CSV file

Posted on 2001-06-11
3
169 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 50 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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

717 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