用于读取由其他用户独占打开的 Excel 文件的 OleDB 连接字符串

发布于 2024-11-04 07:28:02 字数 661 浏览 1 评论 0原文

谁能告诉我 OleDB 连接字符串用于仅读取由其他用户独占打开的 Excel 文件

我尝试了以下连接字符串,但对我不起作用:-

"Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Mode=Read;Extended Properties=\"Excel 8.0;HDR=YES;ReadOnly=true;\"";

当其他用户打开该连接字符串时,该连接字符串会引发以下异常:-

The Microsoft Jet database engine cannot open the file ''.  It is already opened exclusively by another user, or you need permission to view its data.

注意:

  1. Excel 文件保持共享,以便多个用户可以打开它。
  2. 使用的提供程序:- Microsoft.Jet.OLEDB.4.0
  3. Excel 文件类型:- MS Excel 97-2003 工作表
  4. 不允许复制文件

Can anyone tell me OleDB Connection string to be used for just reading an Excel file exclusively opened by other user?

I tried following connection string which did not work for me:-

"Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Mode=Read;Extended Properties=\"Excel 8.0;HDR=YES;ReadOnly=true;\"";

This connection string throws following exception when is it opened by other user:-

The Microsoft Jet database engine cannot open the file ''.  It is already opened exclusively by another user, or you need permission to view its data.

NOTEs:

  1. Excel file is kept on share so that multiple users can open it.
  2. Provider used:- Microsoft.Jet.OLEDB.4.0
  3. Excel file type:- MS Excel 97-2003 Worksheet
  4. Copying a file is NOT allowed

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

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

发布评论

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

评论(1

怼怹恏 2024-11-11 07:28:02

我建议您使用后台线程每隔一段时间重试打开一个连接,当您获得与excel数据源的连接时,将所有数据读入内存并立即关闭连接,以便其他进程可以访问文件。

I would suggest that you use a background thread to retry opening a connection on an interval for some time, and when you get a connection to the excel datasource, read all your data into memory and immediately close the connection, so that other processes can access the file.

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