JamesDBuskirk
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=Delimite d;Database =L:\22\vba pps.2015\S napshotOP\ SSImportOP \bin\x86\R elease\].r ecordtype1 .txt;
If I move the input file to D drive, below works:
SELECT * INTO Record1short
FROM [Text;HDR=Yes;FMT=Delimite d;Database =D:\].reco rdtype1.tx t;
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=Delimite
If I move the input file to D drive, below works:
SELECT * INTO Record1short
FROM [Text;HDR=Yes;FMT=Delimite
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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(|)
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(|)
ASKER
Thanks !!!
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