Link to home
Start Free TrialLog in
Avatar of JamesDBuskirk
JamesDBuskirkFlag for United States of America

asked on

MS Access and Bulk Insert

I am having issues in VB bulk inserting text file to MDB. This is code that works at many client sites. I have resorted to testing my command in Access to make sure it is fit.

below DOES NOT WORK. the data is inserted, but only one column is created and all data goes into one column with the commas.
SELECT * INTO Record1TEST
FROM [Text;HDR=Yes;FMT=Delimited;Database=L:\22\vbapps.2015\SnapshotOP\SSImportOP\bin\x86\Release\].recordtype1.txt;

If I move the input file to D drive, below works:
SELECT * INTO Record1short
FROM [Text;HDR=Yes;FMT=Delimited;Database=D:\].recordtype1.txt;
Avatar of Gustav Brock
Gustav Brock
Flag of Denmark image

This can only be true if you somehow have been granted limited rights to read from that networked folder - or a very bad network connection.
If you can import the same file from any other location, it has to be so.

Alternatively, you may use a completely different method for importing the file as described here:
Import large text file to Access table
ASKER CERTIFIED SOLUTION
Avatar of aikimark
aikimark
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of JamesDBuskirk

ASKER

Aikimark, I think we have a bingo. I found SCHEMA.INI files in my VB application and it is wrong (see below, I am creating COMMA delimited files). Sorry to have missed this I took this project over from another author and did not know of the schema.ini files. Even in Access, the presence of this schema file in the same folder as my import file seems to apply it. I just tested one that failed AFTER changing the schema.ini and it worked! Let me notify my team then I'll award the points. Gustav thank you also for assisting.

Should I fix the schema.ini in my project folder, then build it out to dEBUG/RELEASE or does this get created by VB?

on a rhetorical note, how can Microsoft not be able to figure this out? I spent an two hours on the phone with someone who just kept moving the file around and trying it over and over.

I changed the "|" to "," and now all is well! Thanks again!!!
[recordtype1.txt]
 ColNameHeader=True
 CharacterSet=ANSI
 Format=Delimited(|)
[recordtype3.txt]
 ColNameHeader=True
 CharacterSet=ANSI
 Format=Delimited(|)
[cms.txt]
 ColNameHeader=True
 CharacterSet=ANSI
 Format=Delimited(|)
Thanks !!!