I have some ADO.NET code that uses the Jet OLE DB Provider to read Excel
files. The reading of the files works okay. However, I get strange
behavious when I have Excel running and run the program that reads the file
that Excel currently has loaded. Excel will pop-up messages such as "File
is now available for read-write." In other cases, if I use Excel to modify
the file and save it, then run my program, I get the old data, not the most
recent data.

I think maybe I have to tell the OLE DB provider to open the file in
read-only mode, but I don't know how to do that.

Thanks.
- Kevin

Re: Reading Excel files with Jet OLE DB Provider by Paul

Paul
Tue Sep 02 10:04:00 CDT 2003

On Sun, 31 Aug 2003 10:58:38 -0600, "Kevin Dietz" <kevinzapit1@earthlink.net> wrote:

¤ I have some ADO.NET code that uses the Jet OLE DB Provider to read Excel
¤ files. The reading of the files works okay. However, I get strange
¤ behavious when I have Excel running and run the program that reads the file
¤ that Excel currently has loaded. Excel will pop-up messages such as "File
¤ is now available for read-write." In other cases, if I use Excel to modify
¤ the file and save it, then run my program, I get the old data, not the most
¤ recent data.
¤
¤ I think maybe I have to tell the OLE DB provider to open the file in
¤ read-only mode, but I don't know how to do that.
¤

Do you have the workbook open in shared mode? By default Excel opens workbooks for exclusive access.

You could also try adding Mode=Read to your connection string.


Paul ~~~ pclement@ameritech.net
Microsoft MVP (Visual Basic)