Read Text Files Into a Recordset
Category:Files and Directories
Version Compatibility: Visual Basic 6, Visual Basic 5
This code shows you how to use ADO and the ODBC text driver to open a text file an read it into a recordset. There are two connection strings. The first shows you how to read the file as if there are no headers (i.e., the first row is not treated as column names). The second shows you how to treat the first row as a header. Included are sample data which you can save to a test file to see how it works. A reference to Microsoft's Active Data Objects is required.
Instructions: Copy the declarations and code below and paste directly into your VB project.