Export a Recordset to a Delimited Text File Without Iterating the Recordset

Category:
Database
Type:
Snippets
Difficulty:
Intermediate
Author:
Narinder Pal Singh

Version Compatibility: Visual Basic 6

More information:
This example shows you how to use the file system object and the recordset's GetString method to export recordset data to a delimited text file. In this example, the biblio.mdb that ships with VB is used as an example; obviously, you need to change the Connection string, SQL statement and text file path for your own purpose. The delimiter used is the pipe character, you can change that as well in the call to GetString.

References to ADO 2.1 or above and Microsoft's Scripting Runtime are required.

Instructions: Copy the declarations and code below and paste directly into your VB project.

Declarations:

Code: