Read an entire ado recordset row?

Posted on 2006-03-27
Last Modified: 2010-05-18
Is there a way to read the entire recordset row in order to write to a file in one shot and add delimeters to the fields without looping through each field?
Question by:surfsista9
    LVL 9

    Expert Comment

    by:Naveen Swamy
    getrows and getstring

    check out there help and use it, it is far better than using/looping the rs objects
    LVL 5

    Expert Comment

    You could try incorporating DTS (Data Transformation Services) and Scripting.FileSystemObject, it's a bit long winded but it should work. Infact you could suck the whole recordset in as a DTSFlatFile and spit the lot out to you delimited text file.

    Depending on how your retrieving your recordset? If its coming out of SQL using a stored Procedure it should be pretty easy.

    check this out:
    LVL 5

    Expert Comment


    good point getrows would be A hell of a lot easier!!!!!!!!!!!!!

    Author Comment

    The recordset is coming out of sql. I'd like something that sucks the entire recordset into a file with the option to delimit fields and crlf at each record.

    I'll check out DTSFlatFile.
    LVL 8

    Accepted Solution

    I don't know if there is such a solution, but this one is close

    Dim rs as recordset
    'Fill your recordset from database

    'and write this code
    Dim strRS as string
    Open "c:\rs.csv" for output as #1
    while not rs.eof
     print #1,strData
     ' dont use rs.MoveNext
    close #1
    set rs=nothing

    you can fiddle with the .GetString method to get the format u want


    LVL 8

    Expert Comment

    by:Leo Eikelman
    : )

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Introduction This article makes the case for using two modules in your VBA/VB6 applications to provide both case-sensitive and case-insensitive text comparison operations.  Recently, I solved an EE question using the LIKE function.  In order for th…
    Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
    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…

    760 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

    8 Experts available now in Live!

    Get 1:1 Help Now