Note that there are some explanatory texts on larger screens.

plurals
  1. PO"Invalid attempt to call Read when reader is closed" error (for lengthy operations only)
    primarykey
    data
    text
    <p>We have a operation in which more than 100.000 records are read from a csv file and inserted in a database. When I am using a file with 10 records, the operation is completed successfully in less than one minute.</p> <p>When I use 100.000 records, I am getting the following error “Invalid attempt to call Read when reader is closed.” after 10 minutes. Is there any Timeout that I can configure to avoid this error?</p> <p>Note: The CommandTimeout is already set as zero.</p> <pre><code>DbCommand cmd = db.GetStoredProcCommand("aspInsertZipCode"); cmd.CommandTimeout = 0; dataStringToProcess.Remove(dataStringToProcess.Length - 1, 1); db.AddInParameter(cmd, "@DataRows", DbType.String, dataStringToProcess.ToString()); db.AddInParameter(cmd, "currDate", DbType.DateTime, DateTime.Now); db.AddInParameter(cmd, "userID", DbType.Int32, UserID); db.AddOutParameter(cmd, "CountOfUnchangedZipCode", DbType.String, 1000); DbDataReader rdr = null; try { rdr = (DbDataReader)db.ExecuteReader(cmd); if (rdr.Read()) { if (!String.IsNullOrEmpty(Utility.GetString(rdr, "NewZipCode"))) strNewZipCode = strNewZipCode + "," + Utility.GetString(rdr, "NewZipCode"); } rdr.NextResult(); if (rdr.Read()) { strRetiredZipCode = strRetiredZipCode + "," + Utility.GetString(rdr, "RetiredZipCode"); } int TempUnchageZipCount = Convert.ToInt32(db.GetParameterValue(cmd, "CountOfUnchangedZipCode")); CountOfUnchangedZipCode = CountOfUnchangedZipCode + TempUnchageZipCount; dataStringToProcess = new StringBuilder(); cntRec = 0; } catch { if (rdr != null &amp;&amp; (!rdr.IsClosed)) rdr.Close(); throw; } finally { if (rdr != null &amp;&amp; (!rdr.IsClosed)) rdr.Close(); } cmd.Dispose(); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload