Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2004
    Posts
    53

    Unanswered: exporting recordset to a textfile

    Hello,

    I need to dump a recordset into a tab delimited text file
    Does anyone know a quick way to do this.

    I know how to do it field by field, but I want to dump multiple tables into multiple text files quickly.

    Thanks in advance for any help/suggestions
    Jason

  2. #2
    Join Date
    Mar 2004
    Location
    www.scirocco.ca
    Posts
    346

    Re: exporting recordset to a textfile

    You can Persist the ADO recordset to a text file in XML format using the built-in MS_Persistence provider, you will the have the table structure as well as the data. i.e.

    rs.Save ""c:\testfile.txt", adPersistXML

    Or reference the Microsoft Scripting Object and do it manually. Here is some sample code:

    Dim fso As Scripting.FileSystemObject
    Dim MyFile

    Set fso = new Scripting.FileSystemObject
    Set MyFile = fso.CreateTextFile("c:\testfile.txt", True)
    MyFile.WriteLine(rs.Fields("Field1") & rs/Fields("Fields2"))
    MyFile.Close
    http://www.scirocco.ca/images/banner...occobanner.gif

    Download for FREE the ADO/DAO Data Controls that makes life EASIER developing database applications in: VB, FoxPro, Access, VC++, .NET etc... Navigate, Add New, Delete, Update, Search, Undo and Save your changes. Supports Disconnected Recordsets and Transactions!

    Or try our Ask An Expert service to answer any of your questions!

  3. #3
    Join Date
    Jan 2004
    Posts
    53
    Sorry for not specifing, will this work in VB

    Thanks
    Jason

  4. #4
    Join Date
    Mar 2004
    Location
    www.scirocco.ca
    Posts
    346
    Yes the code is VB code.
    http://www.scirocco.ca/images/banner...occobanner.gif

    Download for FREE the ADO/DAO Data Controls that makes life EASIER developing database applications in: VB, FoxPro, Access, VC++, .NET etc... Navigate, Add New, Delete, Update, Search, Undo and Save your changes. Supports Disconnected Recordsets and Transactions!

    Or try our Ask An Expert service to answer any of your questions!

  5. #5
    Join Date
    Jan 2004
    Posts
    53
    Ok thank you the first option "rs.Save ""c:\testfile.txt", adPersistXML"

    Did not accomplish what I was trying to do.

    Thanks
    Jason

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •