I am experiencing a timeout issue writing data from a dataset into an excel spreadsheet. Here is my connection string currently:
<add key="ExcelConnectionStringHeader" value="Provider=Microsoft.ACE.OLEDB.12.0;Connect Timeout=30;Extended Properties="Excel 12.0;HDR=YES";Data Source="/>
The Connect Timeout property doesn't seem to be supported by the provider. Neither is Connection Timeout, Timeout, ConnectionTimeout, ConnectTimeout, etc. My code created a Data Adapter and and InsertCommand, and updates from a dataset. This works great unless the Update command itself takes more than 15 seconds, which is the default OleDb timeout. Thats why I am trying to set it in the Connection string. I have increased the CommandTimeout from the default of 30, but that is really irrelevant. Below is my Code:
OleDbDataAdapter da = new OleDbDataAdapter(szHeaderSelect, oCnn); // Ratings_Test -- Loan_Test$A1:F1]",
DataSet dsTest = new DataSet();
da.InsertCommand = new OleDbCommand(szNewSQL + "(" + szColumns + ") " + "VALUES ( " + szParams + ")", oCnn);
da.InsertCommand.CommandTimeout = 300;
foreach (DataRow oDr in dtTable.Rows)
{
drNew = dsTest.Tables[0].NewRow();
dsTest.Tables[0].Rows.Add(drNew);
}
var timer = new System.Diagnostics.Stopwatch();
timer.Start();
var recs = da.Update(dsTest, szExcelTab); // Ratings_Test }
timer.Stop();
I omitted the loops and such that actually build the content and parameters of the insert command. Trust me, it all works fine. 2200+ records work fine.
It was after I added the timer that I discovered the problem was timeout. When processing 2221 records, it takes 14.95 seconds and shows up just fine in the spreadsheet. When processing 2260 records, it takes 15.21 seconds and nothing shows up. There are no errors of any kind. I've checked the row state after the update for all rows and they all show no failure.
Bottom line, since the ConnectionTimeout property is ReadOnly, and the provider doesn't seem to support a Timeout in the connection string, what to do....
Thanks.