Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Error in Hashtable with arrayList

Error in Hashtable with arrayList

Scheduled Pinned Locked Moved C#
csharphelpasp-netdatabasedata-structures
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    r aa j
    wrote on last edited by
    #1

    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

    C 1 Reply Last reply
    0
    • R r aa j

      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

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      throw new CrossPostException("Choose a forum for your question and stick to it")

      Christian Graus Driven to the arms of OSX by Vista.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups