Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 174
  • Last Modified:

Saving to a CSV file

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
Frank
Asked:
Frank
1 Solution
 
TimCotteeHead of Software ServicesCommented:
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
 
FrankAuthor Commented:
Many thanks!
0
 
ShaneCourtrilleCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now