This key is already associated with an element of this collection

Discussion in 'ASP General' started by dalberon, Nov 5, 2003.

  1. dalberon

    dalberon Guest

    I am getting this error message with the following piece of code.

    sqlSelect = "Select * from UserPermissions where UserID = " & UserID &
    ";"
    set tbl = GetRecordset(sqlSelect, false)
    while not tbl.eof
    response.write ("<br>key: " & tbl("SectionID"))
    Permissions.add tbl("SectionID"), 1
    tbl.movenext
    wend

    The screen displays
    key: 1
    key: 2

    I've been staring at this problem for two hours now..any suggestions
    would be appreciated.
     
    dalberon, Nov 5, 2003
    #1
    1. Advertising

  2. dalberon

    Ray at Guest

    What is Permissions? A dictionary object? If so, this means that you have
    duplicate values in your SectionID column and as such, you cannot use those
    values as a key in your dictionary object.

    Ray at work

    "dalberon" <> wrote in message
    news:...
    > I am getting this error message with the following piece of code.
    >
    > sqlSelect = "Select * from UserPermissions where UserID = " & UserID &
    > ";"
    > set tbl = GetRecordset(sqlSelect, false)
    > while not tbl.eof
    > response.write ("<br>key: " & tbl("SectionID"))
    > Permissions.add tbl("SectionID"), 1
    > tbl.movenext
    > wend
    >
    > The screen displays
    > key: 1
    > key: 2
    >
    > I've been staring at this problem for two hours now..any suggestions
    > would be appreciated.
     
    Ray at, Nov 5, 2003
    #2
    1. Advertising

  3. http://www.aspfaq.com/2485




    "dalberon" <> wrote in message
    news:...
    > I am getting this error message with the following piece of code.
    >
    > sqlSelect = "Select * from UserPermissions where UserID = " & UserID &
    > ";"
    > set tbl = GetRecordset(sqlSelect, false)
    > while not tbl.eof
    > response.write ("<br>key: " & tbl("SectionID"))
    > Permissions.add tbl("SectionID"), 1
    > tbl.movenext
    > wend
    >
    > The screen displays
    > key: 1
    > key: 2
    >
    > I've been staring at this problem for two hours now..any suggestions
    > would be appreciated.
     
    Aaron Bertrand [MVP], Nov 6, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. James Brown
    Replies:
    1
    Views:
    5,432
    bruce barker
    Jun 26, 2003
  2. Rob Nicholson
    Replies:
    15
    Views:
    20,437
    Rob Nicholson
    Sep 24, 2005
  3. Bart
    Replies:
    13
    Views:
    820
    =?ISO-8859-1?Q?G=F6ran_Andersson?=
    Mar 28, 2007
  4. Øyvind Isaksen
    Replies:
    1
    Views:
    983
    Øyvind Isaksen
    May 18, 2007
  5. Timothy Baron

    Key Associated w/ Maximum Value in Hash

    Timothy Baron, Sep 9, 2010, in forum: Ruby
    Replies:
    10
    Views:
    206
    Benoit Daloze
    Sep 12, 2010
Loading...

Share This Page