I am having a timeout problem while writing data from a dataset to 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 "Connection timeout" property is not supported by the provider. Also there is no connection timeout, timeout, ConnectionTimeout, ConnectTimeout, etc. My code created a data adapter and InsertCommand, as well as updates from a dataset. This works fine if the Update command itself takes more than 15 seconds, which is the default OleDb timeout. That is why I am trying to install it in the Connection line. I have increased the default CommandTimeout to 30, but it really doesn't matter. 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 skipped the loops and thus created the content and parameters of the insert command. Believe me, everything works fine. 2200+ entries work great.
It was after I added the timer that I discovered that the problem was due to a timeout. When processing 2221 records, it takes 14.95 seconds and is displayed in the table only in order. When processing 2260 records, it takes 15.21 seconds and nothing is displayed. There are no errors. I checked the status of the row after updating for all rows, and they all do not detect a failure.
The bottom line, since the ConnectionTimeout property is ReadOnly, and the provider does not seem to support Timeout in the connection string, what to do ....
Thanks.
source share