I am geeting this error for one in thousands messages insert in data
index is out of range.must be non-negative and less than the size of the collection
parameter name:index
Any suggestions to solve this error would be f great help.
i am getting the error in the catch statetment in the below lines:-
if (currentMsgcounter >= msgPerXMLFile || CASQueue.CurrentDepth == 0) { string spErrMsg = ""; try { RSEM_Function dbCall = new RSEM_Function(); //write the RSEM MQ messages to the file with millisecond timestamp //AddDebugLine(" write the RSEM MQ messages to the msg logs file with millisecond timestamp", true); MsgFile = Path.Combine(filePath + @"\RSEMEQP_MsgLogs", string.Format("RSEMQMsg-{0:yyyy-MM-dd_H-mm-ss-ff}.txt", DateTime.Now)); logfile = new RSEM_FileLog(MsgFile); logfile.writeFile(RSEMcompleteMsg.ToString(), "COMPLETE"); //calling the function to insert the Data to T1 table //int recordsInserted = dbCall.insertValues(sConnectionString, xmlFile.ToString()); db = new SqlConnection { ConnectionString = sConnectionString }; SqlCommand cmd = new SqlCommand("feed.spRSEM_Receive", db); //AddDebugLine("insert data to RSEM Receive", true); //calling the SP for to insert the values in RSEM staging table cmd.CommandType = System.Data.CommandType.StoredProcedure; //may not required //string strXml = data.ToString(); // converting XML file to string string @xmlString = xmlFile.ToString(); cmd.Parameters.Add(new SqlParameter("@xmlString", @xmlString)); SqlParameter outParam = cmd.Parameters.Add("@recCount", SqlDbType.Int); outParam.Direction = System.Data.ParameterDirection.Output; SqlParameter outErr = cmd.Parameters.Add("@err", SqlDbType.NVarChar, 1000); outErr.Direction = System.Data.ParameterDirection.Output; cmd.CommandTimeout = 600; db.Open(); cmd.ExecuteNonQuery(); int recordsInserted = Int32.Parse(cmd.Parameters["@recCount"].Value.ToString()); spErrMsg = cmd.Parameters["@err"].Value.ToString(); db.Close(); //Replace the UTF-16 encoding with standard one i.e. UTF-8 xmlFile.Replace(Encoding.Unicode.WebName, Encoding.UTF8.WebName, 0, 56); if (spErrMsg == "" && recordsInserted == 99999) { //write the processed message to the Processed file with millisecond timestamp // AddDebugLine("write the processed message to the Processed file with millisecond timestamp", true); procFile = Path.Combine(filePath + @"\RsEMEQP_ProcessedLogs", string.Format("Processed-{0:yyyyMM-dd_H-mm-ss-ff}.xml", DateTime.Now)); logfile = new RSEM_FileLog(procFile); logfile.writeFile(xmlFile + "\n", "COMPLETE"); } else { elog.WriteErrorToLog(spErrMsg, 4); } } [color="#C0C0C0"]catch (Exception ex) { AddDebugLine("Error while Inserting the messages: " + ex.Message,true); var strError = " "; strError = ("Error while Inserting the messages: " + ex.Message); elog.WriteErrorToLog(strError, 4); }[/color] xmlFile.Remove(0, xmlFile.Length); RSEMcompleteMsg.Remove(0, RKEMcompleteMsg.Length); }
This post has been edited by tlhIn`toq: 23 April 2013 - 05:26 AM
Reason for edit:: Code tags added