T
TB
Greetings,
I use OleDB from my c# application to populate an excel sheet. I open
the connection in a using clause (which automatically close the
connection after exit) and the excel file is created.
However, I am not able to view excel file before I exit the
application. It seems that there is a lock on the excel file and that
the transaction is not fully completed before application close (or
sometimes when I open and close other parts of the application).
Does anyone know a way to force Ole Db to release all locks on the
file? connectionstring setting..?
ConnectionString:
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\"c:\\temp\
\myExcelFile.xls\";Extended Properties=\"Excel 8.0;OLE DB
Services=0;HDR=Yes;Mode = 3;\"";
Tried Services 0/-4
Example code:
using(OleDbConnection connection = new
OleDbConnection(connectionString.ToString()))
{
connection.Open();
transaction =
connection.BeginTransaction(IsolationLevel.ReadUncommitted);
CreateInspectionSheet(inspection, connection, transaction);
transaction.Commit(); // does not seem to force data written
to file
}
transaction.Dispose();
Any help highly appreciated!
-thomas
I use OleDB from my c# application to populate an excel sheet. I open
the connection in a using clause (which automatically close the
connection after exit) and the excel file is created.
However, I am not able to view excel file before I exit the
application. It seems that there is a lock on the excel file and that
the transaction is not fully completed before application close (or
sometimes when I open and close other parts of the application).
Does anyone know a way to force Ole Db to release all locks on the
file? connectionstring setting..?
ConnectionString:
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\"c:\\temp\
\myExcelFile.xls\";Extended Properties=\"Excel 8.0;OLE DB
Services=0;HDR=Yes;Mode = 3;\"";
Tried Services 0/-4
Example code:
using(OleDbConnection connection = new
OleDbConnection(connectionString.ToString()))
{
connection.Open();
transaction =
connection.BeginTransaction(IsolationLevel.ReadUncommitted);
CreateInspectionSheet(inspection, connection, transaction);
transaction.Commit(); // does not seem to force data written
to file
}
transaction.Dispose();
Any help highly appreciated!
-thomas