Reading Excel files with Jet OLE DB Provider

  • Thread starter Thread starter Kevin Dietz
  • Start date Start date
K

Kevin Dietz

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
 
¤ 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 ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 
Back
Top