CSV access via ADO.NET in 64-bit?
Question
In a 32-bit .NET app, I can use this OLEDB connection string to connect to a CSV file via ADO.NET:
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\foo;"
or this ODBC one:
"Driver={{Microsoft Text Driver (*.txt; *.csv)}};Dbq=c:\foo"
However there apparently arent 64-bit versions of either the OLEDB Jet drivers or the ODBC text driver.
I could parse the CSV line by line or run the app in 32-bit mode, but ideally I'd just like to find a different driver that runs as 64-bit.
Any ideas?
Solution
It's not a driver, but I've been pleased with Sebastien Lorion's CSV reader. Note that I've never used it in a 64-bit environment, but I'm not aware of any compatibility issues.
OTHER TIPS
I had this exact same problem and after much trial & error this was what I found that worked:
1. Enable Adhoc procedures
sp_configure 'show advanced options', 1;
RECONFIGURE;
GO
sp_configure 'Ad Hoc Distributed Queries', 1;
RECONFIGURE;
GO
2. Install this file on server:
3. Use this query format:
SELECT * FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0','Text;Database=C:\SQL\;HDR=Yes;','SELECT * FROM [test.csv]');
4. Enable OLE Automation procedures:
sp_configure 'show advanced options', 1;
GO
RECONFIGURE with override
GO
sp_configure 'Ole Automation Procedures', 1;
GO
RECONFIGURE with override;
GO
Alexis,
Do you need a driver at all? If you just need to read a CSV file line by line there are a number of free parsers out there. If you need to also write out a CSV check out FileHelpers.
I ended up having to convert my application to 32-bit because I was having the same problem, although with accessing a Microsoft Access Database. I know this will work, but you may not want this solution. If anyone knows the answer to this question I woud love to hear it as well.
You're in luck-- in December 2010 Microsoft published a a 64-bit OLEDB driver for CSV and XLSX files!
See this answer for download links, install details, connection strings, etc.