Unable to open Excel file in read-only if file already open by another user



Hi

I need to process data from Excel files (into our SQL Server DB) using
SELECT query on a daily basis. The data in these Excel files are
entered by different user departments and they may have the file open
all day (in Exclusive mode).

The code I'm using now works fine as long as the Excel file is closed
(see code below):

Dim cnnXL as ADODB.Connection
Set cnnXL = New ADODB.Connection
cnnXL.Mode = adModeRead
cnnXL.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=X:\Path\Filename.xls;" & _
"Extended Properties=""Excel
8.0;HDR=Yes;IMEX=1"";"

.... [code to retrieve data into recordset, validate and write to SQL
server]

The code throws the following error "The Microsoft Jet Database engine
cannot open the file. It is alredy open by another user, or you need
permission to view its data" as soon as it executes the Open statement
on an already open file. We are using MDAC v2.8,

Any suggestions how to get around this problem?

TIA

Rab

.



Relevant Pages

  • Re: Problems with importing Excel files into SQL Server
    ... I set IMEX=1 in the Extended Properties and the results were ... Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP) ... and most of the Excel files that I ... > I have tried write a convert function into this script, ...
    (microsoft.public.sqlserver.dts)
  • Re: How To Read the Contents of a Directory
    ... Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP) ... www.SQLDTS.com - The site for all your DTS needs. ... >I would like to write a DTS package to import a number of Excel files ... Is there a function to read a predefined network directory to obtain ...
    (microsoft.public.sqlserver.dts)
  • Re: Access databases other than through ODBC?
    ... won't allow access to any Oracle or SQL Server database except to specific ... Excel files that would allow the user to do queries as I've specifically ... The obvious and current solution is to do this through ODBC. ...
    (microsoft.public.excel)
  • Re: Problems with importing Excel files into SQL Server
    ... Settting the IMEX=1 in the DTS Designer package only seemed to work ... > www.SQLDTS.com - The site for all your DTS needs. ... >> I have had problems for years now importing excel files into SQL Server ... and most of the Excel files that I ...
    (microsoft.public.sqlserver.dts)
  • Re: Import MS Excell table using CP
    ... I it was helpfull. ... The samples there allows me to query data from excel files, ... import this data in sql server tables? ...
    (microsoft.public.sqlserver.programming)