Error in Hashtable with arrayList
-
I am developing website using C# with ASP.net. one page I am inserting data into hashtable after reach 1000(>1000),Add it into Array list than Insert into Database...here sometimes saying Exception like Item has already been added. Key in dictionary: '12' Key being added: '12' ...Please help me with this.....How to avoid this Eception... and I am using following code.. public static Hashtable ht = new Hashtable(); public string Crid=""; Crid = ht.Count.ToString(); string[] st = new string[4]; st[0] = Crid; st[1] = "5654546456"; st[2] = "0"; st[3] = "1"; if (ht.Count<1000) { ht.Add(ht.Count, st); } else { ArrayList list = new ArrayList(); foreach (int key in ht.Keys) { list.Add(ht[key]); } ht.Clear(); ht = new Hashtable(); ht.Add(ht.Count, st); for (int j = 0; j < list.Count; j++) { //here Inserting data into Database } }
Raaj
-
I am developing website using C# with ASP.net. one page I am inserting data into hashtable after reach 1000(>1000),Add it into Array list than Insert into Database...here sometimes saying Exception like Item has already been added. Key in dictionary: '12' Key being added: '12' ...Please help me with this.....How to avoid this Eception... and I am using following code.. public static Hashtable ht = new Hashtable(); public string Crid=""; Crid = ht.Count.ToString(); string[] st = new string[4]; st[0] = Crid; st[1] = "5654546456"; st[2] = "0"; st[3] = "1"; if (ht.Count<1000) { ht.Add(ht.Count, st); } else { ArrayList list = new ArrayList(); foreach (int key in ht.Keys) { list.Add(ht[key]); } ht.Clear(); ht = new Hashtable(); ht.Add(ht.Count, st); for (int j = 0; j < list.Count; j++) { //here Inserting data into Database } }
Raaj
throw new CrossPostException("Choose a forum for your question and stick to it")
Christian Graus Driven to the arms of OSX by Vista.