用于读取由其他用户独占打开的 Excel 文件的 OleDB 连接字符串
谁能告诉我 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.
注意:
- Excel 文件保持共享,以便多个用户可以打开它。
- 使用的提供程序:- Microsoft.Jet.OLEDB.4.0
- Excel 文件类型:- MS Excel 97-2003 工作表
- 不允许复制文件
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:
- Excel file is kept on share so that multiple users can open it.
- Provider used:- Microsoft.Jet.OLEDB.4.0
- Excel file type:- MS Excel 97-2003 Worksheet
- Copying a file is NOT allowed
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议您使用后台线程每隔一段时间重试打开一个连接,当您获得与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.