Read Excel file with OleDB c#, when it is used by other process

前端 未结 3 986
执笔经年
执笔经年 2020-12-07 01:45

I am trying to read an excel file every 2 seconds, This file is getting updated by other RTD application.

I am able to read this file by Oledb connection, but probl

3条回答
  •  庸人自扰
    2020-12-07 02:17

    I had similar problem. Below fixes worked for me

    1) Don't hold your connection to sheet. Instead open connection read data and close the connection immediately.

    2) If you are using managed code in the unmanaged application then consider using object of managed type instead of pointer(using gcnew) and use Stack Semantics to make sure that memory is cleaned up when object goes out of scope.

提交回复
热议问题