faqts : Computers : Programming : Languages : Asp : ASP/VBScript : Common Problems : Database and SQL

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

19 of 55 people (35%) answered Yes
Recently 5 of 10 people (50%) answered Yes

Entry

How can I import data from a text file into an Access database?

Nov 25th, 2003 08:21
matt ahorn, unknown unknown, Andrew Gibson


Try this

1. Use FSO to open the text file.
2. Loop through each line and put values into array
3. Write the values to the db.

eg

do while not fname.atendofstream
txt=fname.readline
vals=split(txt,",")     'csv delimited

' insert into db statement using array values

loop

===========================================================
Alternative Method

This assumes that the text file is on the same server as db.
Create a linked table in the db to the text file, such that when you 
open the linked table you can see the text data.

Now this is done you can write select queries to take the information 
from the linked table into different tables in the access db.

I have found this method especially useful when using large text files 
and you only have to replace the text file too add more data.



© 1999-2004 Synop Pty Ltd