|
-
April 13th, 2001, 08:47 AM
#1
Using ADO to read a CSV file
Anyone know how to use ADO to read a csv file?
My requirements are:
Must use ADO
Must use a connection string (Cannot use a DSN)
Thanks for the help
-
April 13th, 2001, 09:35 AM
#2
Re: Using ADO to read a CSV file
Hi,
1.If you may use MS Access or MS Excel, you can store your CSV in them. It's easy to use ADO for MS Access or MS Excel Library for MS Exel.
2.Without ADO: Just read the CSV like a normal text with:
Open fullpath\xxx.csv For Input As #1
Line Input #1, inputstring
and search for each "," with:
InStr(startInt, inputstring, ",", vbBinaryCompare)
CU
UU
-
April 13th, 2001, 10:09 AM
#3
Re: Using ADO to read a CSV file
This code will import csv file into an Access table
Dim appAccess As New Access.Application
'***********************************************************************
'************* Open Access database and transfer file to DB ************
'Must select Access 8 Object Library for Access 97 &
'Access 9 Library for Access 2000 in Project|References
'Open Database DB Path Exclusive
appAccess.OpenCurrentDatabase "Path\Some..MDB", True
' Transfer text file to database
appAccess.DoCmd.TransferText acImportDelim, , "Tablename", "Path\somefile.csv", 1
' Close
appAccess.CloseCurrentDatabase
' Set object to Nothing
Set appAccess = Nothing
Iouri Boutchkine
[email protected]
-
April 13th, 2001, 10:20 AM
#4
Re: Using ADO to read a CSV file
Thank you for your suggestions!! but the code I will be using will be ASP-based on a web server without Access or Excel installed. I could use the FSO to open the file and parse it, but this could become complicated in situations where the seperator character is embedded in the data itself.
I was hoping there would be a simpler way.
-
April 13th, 2001, 10:26 AM
#5
Re: Using ADO to read a CSV file
Nice solution.
(still out of votes...)
Special thanks to Lothar "the Great" Haensler. Come back soon, you Guru.
...at present time, using mainly Net 4.0, Vs 2010
Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|