Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Improving speed to Import a text file into Access DB AD
Message
Information générale
Forum:
Visual Basic
Catégorie:
Bases de données DAO/RDO/ODBC/ADO
Divers
Thread ID:
00601606
Message ID:
00602341
Vues:
28
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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform