none
Reading Excel File using OLEDB RRS feed

  • Question

  • I am reading excel using ACE.OLEDB.12 engine. When multiple files are being read, the application throws the below error. This error is thrown only when multiple excel files are processed. I am closing the connection and using OleDbConnection.ReleaseObjectPool() to release the pool.

    When using memory profiler, there are instances which are garbage collected without being properly disposed. Those instances include System.Data.Oledb.DataSourceWrapper and System.Data.Oledb.SessionWrapper. Is this the reason for the below error? If so what should be done to dispose this? Please suggest.

    The Microsoft Office Access database engine cannot open or write to the file ''. It is already opened exclusively by another user, or you need permission to view and write its data. at System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString constr, OleDbConnection connection)
       at System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject)
       at System.Data.ProviderBase.DbConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
       at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup, DbConnectionOptions userOptions)
       at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
       at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
       at System.Data.ProviderBase.DbConnectionInternal.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
       at System.Data.OleDb.OleDbConnection.Open()

    Saturday, January 12, 2019 10:30 AM

All replies

  • I am reading excel using ACE.OLEDB.12 engine. When multiple files are being read, the application throws the below error. This error is thrown only when multiple excel files are processed. 

    The Microsoft Office Access database engine cannot open or write to the file ''. It is already opened exclusively by another user, or you need permission to view and write its data. 

    Hi,

    Could you please provide the related code here to reproduce this issue?

    What do you mean that multiple files are being read?

    For this error, please make sure you have read/write permissions on the file with your user, and make sure no one has a lock on the file.

    Please refer to the following similar thread:

    C# Access Database In use or Permission Failure

    Regards,

    Stanly


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, January 14, 2019 5:46 AM
  • When files are uploaded by multiple users at a time, I am getting this error. These are different files. When stress testing is done using 100 files, say after processing 20 files, this error is thrown.
    Monday, January 14, 2019 7:59 AM
  • Perhaps the upload process did not finish yet. If you cannot determine when the file is ready, then maybe ignore the error and retry the operation. (Or, as a preliminary test before invoking the engine, maybe check the availability trying to open and close the file using FileStream, for example).

    • Edited by Viorel_MVP Monday, January 14, 2019 8:35 AM
    Monday, January 14, 2019 8:34 AM
  • I am already performing the retry option within the code. That is if the file is getting failed, it will keep on trying for 3 times.
    Monday, January 14, 2019 12:09 PM
  • Hi,

    Sorry but I still can not reproduce this issue, could you provide some related code about it?

    Regards,

    Stanly


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, January 25, 2019 2:39 AM
  • Hi ANair,

    Is there any update? is the issue still exist? Please feel free let us know.

    Best regards,

    Zhanglong


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, February 4, 2019 7:14 AM
    Moderator