通过 64 位 ADO.NET 访问 CSV?

发布于 2024-07-11 06:25:08 字数 392 浏览 3 评论 0原文

在 32 位 .NET 应用程序中,我可以使用此 OLEDB 连接字符串通过 ADO.NET 连接到 CSV 文件:

"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\foo;"

或此 ODBC 连接字符串:

"Driver={{Microsoft Text Driver (*.txt; *.csv)}};Dbq=c:\foo"

但是显然没有 OLEDB Jet 驱动程序或 ODBC 文本的 64 位版本司机。

我可以逐行解析 CSV 或以 32 位模式运行应用程序,但理想情况下我只想找到一个以 64 位运行的不同驱动程序。

有任何想法吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

み零 2024-07-18 06:25:09

它不是驱动程序,但我对 Sebastien Lorion 的 CSV 阅读器很满意。 请注意,我从未在 64 位环境中使用过它,但我不知道有任何兼容性问题。

http://www.codeproject.com/KB/database/CsvReader.aspx

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.

http://www.codeproject.com/KB/database/CsvReader.aspx

我不是你的备胎 2024-07-18 06:25:09

亚历克西斯,

你需要司机吗? 如果您只需要逐行读取 CSV 文件,可以使用许多免费的解析器。 如果您还需要编写 CSV,请查看 FileHelpers

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.

星星的軌跡 2024-07-18 06:25:09

您很幸运 - 2010 年 12 月,Microsoft 发布了用于 CSV 和 XLSX 文件的 64 位 OLEDB 驱动程序!

有关下载链接、安装详细信息、连接字符串等,请参阅此答案

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.

静谧幽蓝 2024-07-18 06:25:09

我最终不得不将我的应用程序转换为 32 位,因为我遇到了同样的问题,尽管访问 Microsoft Access 数据库。 我知道这会起作用,但您可能不想要这个解决方案。 如果有人知道这个问题的答案,我也很想听听。

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.

樱桃奶球 2024-07-18 06:25:08

我遇到了同样的问题,经过多次尝试和尝试后,我遇到了同样的问题。 错误这是我发现有效的:

1。 启用临时程序

sp_configure 'show advanced options', 1;
RECONFIGURE;
GO
sp_configure 'Ad Hoc Distributed Queries', 1;
RECONFIGURE;
GO

2。 在服务器上安装此文件:

http://www.microsoft.com/downloads/en/details.aspx?familyid=C06B8369-60DD-4B64-A44B-84B371EDE16D&displaylang=en

3. 使用此查询格式:

SELECT * FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0','Text;Database=C:\SQL\;HDR=Yes;','SELECT * FROM [test.csv]');

4. 启用 OLE 自动化过程:

sp_configure 'show advanced options', 1;
GO
RECONFIGURE with override
GO
sp_configure 'Ole Automation Procedures', 1;
GO
RECONFIGURE with override;
GO

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:

http://www.microsoft.com/downloads/en/details.aspx?familyid=C06B8369-60DD-4B64-A44B-84B371EDE16D&displaylang=en

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文