Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Improving speed to Import a text file into Access DB AD
Message
General information
Forum:
Visual Basic
Category:
Database DAO/RDO/ODBC/ADO
Miscellaneous
Thread ID:
00601606
Message ID:
00602341
Views:
27
If your using VB to import your text file into Access you may find the following code snippet quite useful:

Dim dbsWQ As New ADODB.Connection, strSQL As String, strCn As String

' Prepare to import CSV files
strCn = "Driver={Microsoft Text Driver (*.txt; *.csv)};" & _
"DBQ={Your path to Access DB};" & _
"DefaultDir={Your path to Access DB};" & _
"Uid=Admin;Pwd=;"
dbsWQ.Open strCn

strSQL = "SELECT * INTO [{Temp Table Name}] IN '{Access DB Name}'" & _
" FROM {Text File Name}"
dbsWQ.Execute strSQL

dbsWQ.Close

You should substitute your specific information for items enclosed in {}.

I have used this on fairly large text files and it seems to work respectably. Once you have the data in a temp table it would be just a matter of checking the character values at the necessary record offset in the 'where' clause of your Append Query. The first line of your text file will be used for the field definitions.

Be sure to include a backslash at the end of {Your path to Access DB}.
Karriem A. Shabazz
4MF Software Solutions
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform