6

谁能告诉我 OleDB 连接字符串仅用于读取exclusively其他用户打开的 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. 不允许复制文件
4

1 回答 1

0

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

于 2012-06-30T02:17:24.823 回答