Dictionary object

Results 1 to 2 of 2

Thread: Dictionary object

  1. #1
    Corin Guest

    Default Dictionary object

    Not sure why this code works;<BR><BR>dim people(3) <BR><BR>Set people(0) = server.CreateObject("Scripting.Dictionary") <BR>people(0).Add "fname", "Jane" <BR>people(0).Add "lname", "Doe" <BR>people(0).Add "haircolor", "brown" <BR>people(0).add "eyecolor" , "blue" <BR>people(0).add "dateofbirth", "1/10/60"<BR><BR>Yet I try;<BR><BR>rs.MoveFirst<BR> <BR>dim content(1) <BR><BR>Set content(0) = server.CreateObject("Scripting.Dictionary") <BR> <BR>While Not rs2.EOF<BR>content(0).Add rs.fields("Name"), rs.fields("Text")<BR>rs.movenext<BR>WEND<BR> <BR>The db connection and db fields are all correct but i get the following error;<BR><BR>Microsoft VBScript runtime error &#039 800a01c9&#039 <BR>This key is already associated with an element of this collection <BR><BR>any help would be greatly apprecited <BR>

  2. #2

    Default RE: Dictionary object

    While Not rs2.EOF<BR>&nbsp;&nbsp;&nbsp;&nbsp;content(0).Add rs.fields("Name"), rs.fields("Text")<BR>&nbsp;&nbsp;&nbsp;&nbsp;rs.mo venext<BR>WEND<BR><BR>*****************<BR><BR>In that code, did you try doing a tiny little bit of debugging? Such as doing <BR>&nbsp;&nbsp;&nbsp;&nbsp;Response.Write "Name=" & rs.fields("Name") & ",text=" & rs.fields("Text") & "&LT;BR&GT;"<BR>???<BR><BR>I betcha that would have immediately showed you your problem.<BR><BR>You have two records in that recordset that have the same value for rs.fields("Name"). Betcha. And the error message is telling you literally and exactly what your bug is. Betcha.<BR><BR>And even if that is *not* the problem, then *still* even the barest little bit of debuggging would help you find what it is. Betcha.<BR><BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts