I am importing/inserting data from a .csv file to a MS Access database. Some of the fields in the .csv file has quotation marks in them, others not (if the field contains a comma, the field is placed within quotation marks). The fact that only some fields contain quotation marks causes the import to skip each row which contains a field with quotation marks (fields without quotation marks are imported fine).
How do I import/insert all fields (irrespective of quotation marks)?
Here is my connectionstring to dabase:
Set conn = New ADODB.Connection
conn.open = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=somefolder\database.accdb"
Here is my query that inserts data from .csv file (UTF-8) into database (.csv file is indeed comma-separated):
Set rs = New ADODB.Recordset
Query = "INSERT INTO [table] SELECT * FROM [" & strCSVFileName & "] " _
& "IN """ & strCSVFolder & """ ""Text;HDR=Yes;FMT=Delimited;CharacterSet=65001;"""
rs.Open Query, conn
Brief background
The database will be updated daily by colleagues of mine with no interest in VBA or databases. Hence, the import/insert has to be automated and run from a macro contained in Excel.
UPDATE: I ended up parsing the .csv file with Adodb Stream (since FileSystemObject does not seem to be able to handle UTF-8). I have access to the .csv files also as tab-delimited, which I though would be easier to handle with Adodb Stream (but which I knew I could not correctly read with above described approach). However, tab-delimited .csv files seem to difficult to deal with everywhere - so I stuck with the comma-delimited file format and did what Gustav suggested; cleaned up each row to get rid of quotation marks.
Now that I have it working, I am happy I have gone this way, since I have been able to correct other problems in the .csv files, and since each .csv file only take about 3 seconds to parse, clean and insert into database.