Hi,
I'm using asp.net to generate excel files with data read from another source (Oracle for example). I'm using Oledb data provider for ado.net (.net framework 1.1). When I generate a small excel file everything goes fine, but when I generate large excel files (i.e. 500K), I get the following error:
"The process cannot access the file ... because it is being used by another process".
I have found that in the case of large files, the connection object maintains the file open even after I close the connection object.
The relevant code is this:
Dim conn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & "12345.xls" & _
";Extended Properties='Excel 8.0;HDR=No;'")
conn.open()
... send data to the file...
conn.close()
//with small files, the .xls file shows its real size (with the new data) and the connection object doesn't keep the file opened.
//but with large files, the .xls file maintains its original size, in my case, 25 K, and all the data that I've sent is not showed, and I get the previous error. I think the data is stored in a cache in memory before being sent to the file.
When I shut down the aspnet_wp.exe, the file is freed and the .xls file now shows its real size, it means, 500K. So, I don't lose the data.
Is there any way to control the content of this buffer? I have found that if I close and open the connection in regular intervals, the data is sent to the file in small blocks, it fixes the problem, but I'm looking for another solution.
Thanks in advance
José Carlos
JOSE CARLOS ARAMBURU
josecarloaa@hotmail.com
I'm using asp.net to generate excel files with data read from another source (Oracle for example). I'm using Oledb data provider for ado.net (.net framework 1.1). When I generate a small excel file everything goes fine, but when I generate large excel files (i.e. 500K), I get the following error:
"The process cannot access the file ... because it is being used by another process".
I have found that in the case of large files, the connection object maintains the file open even after I close the connection object.
The relevant code is this:
Dim conn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & "12345.xls" & _
";Extended Properties='Excel 8.0;HDR=No;'")
conn.open()
... send data to the file...
conn.close()
//with small files, the .xls file shows its real size (with the new data) and the connection object doesn't keep the file opened.
//but with large files, the .xls file maintains its original size, in my case, 25 K, and all the data that I've sent is not showed, and I get the previous error. I think the data is stored in a cache in memory before being sent to the file.
When I shut down the aspnet_wp.exe, the file is freed and the .xls file now shows its real size, it means, 500K. So, I don't lose the data.
Is there any way to control the content of this buffer? I have found that if I close and open the connection in regular intervals, the data is sent to the file in small blocks, it fixes the problem, but I'm looking for another solution.
Thanks in advance
José Carlos
JOSE CARLOS ARAMBURU
josecarloaa@hotmail.com