LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default ADO: Read Excel file that is in use (locked)

Is it possible to read an Excel file with ADO if the file is allready opened
by someone(for editing)? I think that it should be possible to open the file
as read only but I keep getting the error:

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.

I am running the (javascript asp) code below on an intranet server. The
server reads an Excel file on a file server to extract information.
Everything works fine unless some user has the file open.

I know that this error may occur when there are file permissions errors for
in IUSR_computerName user but I am pretty sure I do not have these problems.
The errors occur on the line below with conn.Open(). Is there any way I have
not used that I can instruct JET OLEDB to open the file as read only. (except
for conn.Mode = adModeRead that does not appear to do what I expect it to, to
be able to read an open file)

My code is as follows:

var resRS = Server.CreateObject("ADODB.Recordset");
resRS.CursorType = adOpenKeyset;
resRS.CursorLocation = adUseClient;
resRS.LockType = adLockReadOnly;

var conn = Server.CreateObject("ADODB.Connection");
connString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=";
connString += "\\\\OtherMachine\\Temp\\test.xls" + ";Extended
Properties='Excel 8.0;IMEX=1';";
conn.Mode = adModeRead;

// This line generates the error
conn.Open(connString);

var sql = "SELECT MyName, MyValue FROM [Summary$]";
resRS.Open(sql, conn);

Any help most appreciated. Maybe this is something that just cannot be done.

Best regards,

Andreas Stansvik
Software Developer
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel file locked and cannot delete file Simka Excel Discussion (Misc queries) 7 May 12th 09 10:46 AM
file is locked does not appear in Excel if file already open by an Leslie New Users to Excel 3 April 10th 06 09:40 PM
locked out of my sheet for read only wwoody Excel Worksheet Functions 1 March 1st 06 01:52 AM
"Unable to read file" error message when opening a Excel file that contains a PivotTable report. Tim Marsden Charts and Charting in Excel 2 October 15th 05 02:10 PM
Trying to Open Excel File, But its says file is locked for editing Smeeta Geary Excel Discussion (Misc queries) 1 September 20th 05 01:28 PM


All times are GMT +1. The time now is 01:45 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"