NEED HELP on Dictionary OBJECT!!!!!!!!

Results 1 to 4 of 4

Thread: NEED HELP on Dictionary OBJECT!!!!!!!!

  1. #1
    beefturkey Guest

    Default NEED HELP on Dictionary OBJECT!!!!!!!!

    Here&#039s the code:<BR><BR>Set DivRS = Conn.Execute("Select division_code,division_position from division")<BR>Set posObj = createobject("Scripting.Dictionary")<BR>Do Until DivRS.EOF<BR> posObj.Add DivRS("division_code"),DivRS("division_position")< BR> divRS.movenext<BR>Loop<BR><BR>Here&#039s the error:<BR><BR>Microsoft VBScript runtime error &#039 800a01c9&#039 <BR><BR>This key is already associated with an element of this collection <BR><BR>/getPosition.asp, line 10 <BR><BR>Line 10 is where the "ADD" method is. Look&#039s like posObj.ADD reading the key litterally as "DivRS("division_code")" instead of its value.<BR><BR>anyone know why ... if not, can someone tell me any other ways to do the same thing??<BR><BR>thanks a million

  2. #2
    Shedao Shai Guest

    Default RE: NEED HELP on ..

    Have you tried placing the returned recordset values into<BR>local variable BEFORE trying to add them? Like:<BR><BR>Do Until DivRS.EOF<BR>strDivCode = DivRS("division_code")<BR>strDivPosition = DivRS("division_position")<BR>posObj.Add strDivCode, strDivCode<BR>DivRS.movenext<BR><BR><BR>Try this and tell us what happens.<BR><BR><BR>

  3. #3
    Doug Seven Guest

    Default RE: NEED HELP on ..

    DivRS("division_code") must be unique in each instance of ADD<BR><BR>Add Method (Dictionary) <BR>Adds a key and item pair to a Dictionary object.<BR><BR>Syntax<BR>object.Add key, item<BR><BR>The Add method has the following parts:<BR>object - Required. Always the name of a Dictionary object. <BR>key - Required. The key associated with the item being added. <BR>item - Required. The item associated with the key being added. <BR><BR>Remarks<BR>An error occurs if the key already exists.<BR><BR>Doug Seven<BR>CodeJunkies.Net /<BR><BR>

  4. #4
    Shedao Shai Guest

    Default RE: NEED HELP on Dictionary OBJECT!!!!!!!!

    You know I didn&#039t look closely enough at this problem.<BR>The add method will only add new entries.<BR><BR>If you want to update one you must set the value for that<BR>item like this:<BR><BR>posObj.Item(DivRS("division_code")) = DivRs("division_position")<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