Why am I getting index out of bounds error from database <p>I know what index out of bounds is all about. When I debug I see why as well. basically what is happening is I do a filter on my database to look for records that are potential/pending. I then gather a array of those numbers send them off to another server to check to see if those numbers have been upgraded to a sale. If it has been upgraded to a sale the server responds back with the new Sales Order ID and my old Pending Sales Order ID (SourceID). I then do a for loop on that list to filter it down that specific SourceID and update the SourceID to be the Sales Order ID and change a couple of other values. Problem is is that when I use that filter on the very first one it throws a index out of bounds error. I check the results returned by the filter and it says 0. Which i find kind of strange because I took the sales order number from the list so it should be there. So i dont know what the deal is. Here is the code in question that throws the error. And it doesn't do it all the time. Like I just ran the code this morning and it didn't throw the error. But last night it did before I went home.</p> <pre><code> filter.RowFilter = string.Format("Stage = '{0}'", Potential.PotentialSale); if (filter.Count &gt; 0) { var Soids = new int[filter.Count]; Console.Write("Searching for Soids - ("); for (int i = 0; i &lt; filter.Count; i++) { Console.Write(filter[i][1].ToString() + ","); Soids[i] = (int)filter[i][1]; } Console.WriteLine(")"); var pendingRecords = Server.GetSoldRecords(Soids); var updateRecords = new NameValueCollection(); for (int i = 0; i &lt; pendingRecords.Length; i++) { filter.RowFilter = "Soid = " + pendingRecords[i][1]; filter[0].Row["Soid"] = pendingRecords[i][0]; filter[0].Row["SourceId"] = pendingRecords[i][1]; filter[0].Row["Stage"] = Potential.ClosedWon; var potentialXML = Potential.GetUpdatePotentialXML(filter[0].Row["Soid"].ToString(), filter[0].Row["Stage"].ToString()); updateRecords.Add(filter[0].Row["ZohoID"].ToString(), potentialXML); } </code></pre> <p>if i'm counting right line 17 is the error where the error is thrown. pendingRecords is a object[][] array. pendingRecords[i] is the individual records. pendingRecords[i][0] is the new Sales OrderID (SOID) and pendingRecords[i][1] is the old SOID (now the SourceID)</p> <p>Any help on this one? is it because i'm changing the SOID to the new SOID, and the filter auto updates itself? I just don't know</p>