![]() |
After oledb inset in Excel, 'Cannot Access file' error on Excel
Hi,
I have C# code that uses Jet.OLEDB.4.0 to write to an excel file. After performing inserts using an 'insert into' SQL query, I close the connection and reopen the file using excel objects for performing some other operations on the file. If the data being written using oledb is large (more than 1K records), excel throws an error 'Cannot Access File' while opening the file using Excel objects. If the data is less around 500 records, the exception is not thrown. I feel the reason for exception is that before the file is released by oledb, the excel objects try to operate on it. How do I make sure that the oledb has finished its writing and the file is released, so that excel does not throw exception. Thanks & regards, Prachi |
After oledb inset in Excel, 'Cannot Access file' error on Excel
Is there a background setting that allows the writing to be done
asynchronously - if so, set that to false so the code does not continue until the writing is done. -- Regards, Tom Ogilvy "Prachi" wrote in message m... Hi, I have C# code that uses Jet.OLEDB.4.0 to write to an excel file. After performing inserts using an 'insert into' SQL query, I close the connection and reopen the file using excel objects for performing some other operations on the file. If the data being written using oledb is large (more than 1K records), excel throws an error 'Cannot Access File' while opening the file using Excel objects. If the data is less around 500 records, the exception is not thrown. I feel the reason for exception is that before the file is released by oledb, the excel objects try to operate on it. How do I make sure that the oledb has finished its writing and the file is released, so that excel does not throw exception. Thanks & regards, Prachi |
After oledb inset in Excel, 'Cannot Access file' error on Excel
Hi Tom,
Thanks a lot!! I did find a registry setting that enforces synchronous writes on Oledb Jet provider. Thanks again, Prachi "Tom Ogilvy" wrote in message ... Is there a background setting that allows the writing to be done asynchronously - if so, set that to false so the code does not continue until the writing is done. -- Regards, Tom Ogilvy |
All times are GMT +1. The time now is 12:07 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com