OleDB Connection string for reading an Excel file opened by another user

Can someone tell me the OleDB Connection line, which will be used for read-only Excel file exclusively opened by another user ?

I tried the 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 the following exception when it is opened by another 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. 

NOTE:

  • The Excel file is stored on a shared resource, so several users can open it.
  • Supplier Used: - Microsoft.Jet.OLEDB.4.0
  • Excel file type: - Worksheet MS Excel 97-2003
  • File Copy NOT Allowed
+6
source share
1 answer

I would suggest that you use the background thread to reopen the connection on the interval for some time, and when you get the connection to the excel data source, read all your data in memory and close the connection immediately so that other processes can access the file.

0
source

Source: https://habr.com/ru/post/887098/


All Articles