Reading Excel files with Jet OLE DB Provider

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
 
P

Paul Clement

¤ 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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top