Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7947421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T01:25:37+00:00 2026-06-04T01:25:37+00:00

I know what index out of bounds is all about. When I debug I

  • 0

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.

        filter.RowFilter = string.Format("Stage = '{0}'", Potential.PotentialSale);
        if (filter.Count > 0)
        {
            var Soids = new int[filter.Count];
            Console.Write("Searching for Soids - (");
            for (int i = 0; i < 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 < 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);
            }

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)

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T01:25:39+00:00Added an answer on June 4, 2026 at 1:25 am

    Well I ended up changing how it worked all together and it actually sorts it a bit nicer now. The code i am about to post has a bunch of hard coded numbers due to the structure of my table that is returned. Sorry about that. I have learned since then to not do that, but i am working on a different project now and will change that when I have to change the program. But here is the solution.

            var potentials = Server.GetNewPotentials(); //loads all records from server
            for (int i = 0; i < potentials.Length; i++)
            {
                var filter = AllPotentials.DefaultView;
                var result1 = CheckSoidOrSource(potentials[i].Soid, true);
                var result2 = CheckSoidOrSource(potentials[i].SourceID,false) ;
                //This potential can't be found at all so let's add it to our table
                if (result1+result2==0)
                {
                    Logger.WriteLine("Found new record. Adding it to DataTable and sending it to Zoho");
                    AllPotentials.Add(potentials[i]);
                    filter.RowFilter = string.Format("Soid = '{0}'", potentials[i].SourceID);
                    var index = AllPotentials.Rows.IndexOf(filter[0].Row);
                    ZohoPoster posterInsert = new ZohoPoster(Zoho.Fields.Potentials, Zoho.Calls.insertRecords);
                    AllPotentials.Rows[index]["ZohoID"] = posterInsert.PostNewPotentialRecord(3, filter[0].Row);
                }
                //This potential is not found, but has a SourceId that matches a Soid of another record.
                if (result1==0 && result2 == 1)
                {
                    Logger.WriteLine("Found a record that needs to be updated on Zoho");
                    ZohoPoster posterUpdate = new ZohoPoster(Zoho.Fields.Potentials, Zoho.Calls.updateRecords);
    
                    filter.RowFilter = string.Format("Soid = '{0}'", potentials[i].SourceID);
                    var index = AllPotentials.Rows.IndexOf(filter[0].Row);
                    AllPotentials.Rows[index]["Soid"] = potentials[i].Soid;
                    AllPotentials.Rows[index]["SourceId"] = potentials[i].SourceID;
                    AllPotentials.Rows[index]["PotentialStage"] = potentials[i].PotentialStage;
                    AllPotentials.Rows[index]["UpdateRecord"] = true;
                    AllPotentials.Rows[index]["Amount"] = potentials[i].Amount;
                    AllPotentials.Rows[index]["ZohoID"] = posterUpdate.UpdatePotentialRecord(3, filter[0].Row);
                }
            }
            AllPotentials.AcceptChanges();
        }
        private int CheckSoidOrSource(string Soid, bool checkSource)
        {
            var filter = AllPotentials.DefaultView;
            if (checkSource)
                filter.RowFilter = string.Format("Soid = '{0}' OR SourceId = '{1}'",Soid, Soid);
            else
                filter.RowFilter = string.Format("Soid = '{0}'", Soid);
    
            return filter.Count;
        } 
    

    basically what is happening is that i noticed something about my data when I filter it this way. The two results would only return the following results (0,0) (0,1) and (1,0) (0,0) means that the record doesn’t exist at all in this table so I need to add it. (1,0) means that the Sales Order ID (Soid) matches another Soid in the table so it already exists. Lastly (0,1) means that the Soid doesn’t exist in this table but i found a record that has the Soid as it’s source…which to me means that the one that had it as a source has been upgraded from a potential to a sale, which in turn means i have to update the record and Zoho. This worked out to much less work for me because now I don’t have to search for won and lost records, i only have to search for lost records. less code same results is always a good thing 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to find out a way to know the index of a anchor
I know how to work out the index of a certain character or number
I am getting the following index out of bounds error: *** Terminating app due
I want to know column index of header in AdvancedDataGrid when a user clicks
After googling i came to know that Index seek is better than scan. How
I have a xml document. I know the index where i need to insert
So let's say I have a matrix, mdat and I only know the index
Is there a progmmatic way in Lucene to know if the index is optimized
On clicking child, I want to know the parent index no. Example, there is
I know how to use INDEX as in the following code. And I know

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.