c# - "Invalid attempt to call Read when reader is closed" error (for lengthy operations only) -


we have operation in more 100.000 records read csv file , inserted in database. when using file 10 records, operation completed in less 1 minute.

when use 100.000 records, getting following error “invalid attempt call read when reader closed.” after 10 minutes. there timeout can configure avoid error?

note: commandtimeout set zero.

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 && (!rdr.isclosed))         rdr.close();     throw; } {     if (rdr != null && (!rdr.isclosed))         rdr.close(); } cmd.dispose(); 

could database timeout instead... checked that?

what trying anyway? if need read many rows perhaps consider reducing smaller chunks - say, read 1000 @ time


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -