Last post Mar 18, 2007 10:24 PM by HiTech2k
Mar 06, 2007 02:06 PM|Dmelian|LINK
Is there any way to open an excel spread sheet for read only if it is currently open by a user. I'm running into the problem that if the file is use or open by a user I'm unable to read the contexts. I have include my code below. Thanks for your help in
Set cn = New ADODB.Connection
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strFileTarget & ";Extended Properties=""Excel 8.0;HDR=Yes"""
Set rsFile = New ADODB.Recordset
rsFile.CursorLocation = adUseClient
rsFile.Open "SELECT * FROM [OpenPOData$]", cn, adOpenDynamic, adLockOptimistic
Mar 07, 2007 04:07 AM|Mikesdotnetting|LINK
There doesn't seem to be. Out of curiosity, I even tried using the ODBC driver, because that is readonly by default, but that throws an error if the document is already open.
Mar 18, 2007 10:24 PM|HiTech2k|LINK
You have to make sure that the file is closed so that the ASP.NET process can open it exclusively.
Using the ADO drivers such as Excel and Access in ASP.NET is generally speaking a no-no, except for single-user scenarios. You can't expect multi-user database functionality from a single-user file-based driver. Due to its multi-user nature, ASP.NET is multithreaded.
The only scenario where Excel/Access data read/write might be acceptable is if the files are to be used for a single-operation only by a single user, e.g. Excel import to the database over the web. But even in that case, don't take concurrency for granted.