Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
File access error in Excel Mark Lang Excel Discussion (Misc queries) 0 January 12th 10 07:31 PM
Microsoft.Jet.OLEDB error with csv file names [email protected] Excel Discussion (Misc queries) 0 May 14th 08 02:21 PM
When opening Excel - get Access (Read-Only) file and error DeltaDagger Setting up and Configuration of Excel 1 October 31st 06 10:22 AM
i cannot open excel file error Cannot access read-only document me Lenda. Excel Worksheet Functions 1 March 14th 05 06:15 PM
Query OLEDB Provider for Excel file info? mike Excel Programming 5 January 15th 04 12:33 PM


All times are GMT +1. The time now is 07:32 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"