If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Delphi, C etc > exporting recordset to a textfile

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-02-04, 14:11
jhuck jhuck is offline
Registered User
 
Join Date: Jan 2004
Posts: 53
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
Reply With Quote
  #2 (permalink)  
Old 04-02-04, 20:08
SCIROCCO SCIROCCO is offline
Registered User
 
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!
Reply With Quote
  #3 (permalink)  
Old 04-05-04, 15:51
jhuck jhuck is offline
Registered User
 
Join Date: Jan 2004
Posts: 53
Sorry for not specifing, will this work in VB

Thanks
__________________
Jason
Reply With Quote
  #4 (permalink)  
Old 04-05-04, 16:18
SCIROCCO SCIROCCO is offline
Registered User
 
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!
Reply With Quote
  #5 (permalink)  
Old 04-06-04, 11:44
jhuck jhuck is offline
Registered User
 
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On