Wrox Programmer Forums
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old July 23rd, 2004, 10:48 AM
Registered User
Join Date: Jul 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to andersoni
Default Exception Error using Dictionary Object

I am receiving an exception error when trying to display the items in a dictionary object.

First, here is my code,

     Sub AddItem
          '** get list of other items already for this member and place in dictionary **
          Dim intMemRefNum
          Dim blnNoMemSplItems

          blnNoMemSplItems = 0
          intMemRefNum = request.Form ("intMemRefNum")
          strSQL = "SELECT DetRefNum FROM tblSplPrice WHERE MemRefNum = " & intMemRefNum
          Set rst1 = ECommDB.Execute(strSQL)

          If rst1.EOF Then
               blnNoMemSplItems = 1
               Dim dictMemSplItems
               Dim intCounter
               Dim strItem

               Set dictMemSplItems = Server.CreateObject("Scripting.Dictionary")
               intCounter = 0
               Do While NOT rst1.EOF
                    '** get ordernum from tblProductdetail based on DetRefNum in tblSplPrice **
                    strSQL = "SELECT OrderNum FROM tblProductDetail WHERE DetRefNum = " & rst1("DetRefNum")
                    Set rst2 = ECommDB.Execute(strSQL)

                    Do While NOT rst2.EOF
                         strItem = "item" & CStr(intCounter)
response.write "add to dictionary = " & strItem & "&nbsp;&nbsp;&nbsp;&nbsp;ordernum = " & rst2("OrderNum") & "<br>"

                         dictMemSplItems.Add strItem, rst2("OrderNum")
response.write "dict item = " & dictMemSplItems.item(strItem) & "<br>"
                         intCounter = intCounter + 1
          End If
          Set rst1 = Nothing
          Set rst2 = Nothing

          response.write "item = " & dictMemSplItems.item("item0") & "<br>"

          Dim y
          for y = 0 to 10
               strItem = "item" & CStr(y)
               response.write "item = " & dictMemSplItems.item(strItem) & "<br>"

          set dictMemSplItems = Nothing
     End Sub

Second, the error message,

error '80020009'
Exception occurred.

/SiteAdmin/AdmSpecialPricingMulti.asp, line 42

What I am doing is getting some information from one table and then checking it against another table. If there are items in the first table (NOT rst1.EOF) then it pulls up specific information from another table and places it is a dictionary. The dictionary keys are simply based on a counter that is incrimenting on each item added to the dictionary.

The items are being placed in the dictionary fine. You will notice a couple of response.write items. These are simply to verify what is to be written to the dictionary and what is being written. When I run the code, all of the response.write lines work fine. Here is a sample,

add to dictionary = item0 ordernum = SNA433-7
dict item = SNA433-7
add to dictionary = item1 ordernum = KNKT14025BX
dict item = KNKT14025BX
add to dictionary = item2 ordernum = SNA433-8
dict item = SNA433-8
add to dictionary = item3 ordernum = SNA433-9
dict item = SNA433-9
add to dictionary = item4 ordernum = SNA433-10
dict item = SNA433-10
add to dictionary = item5 ordernum = SNA433-10
dict item = SNA433-10

The problem is after the Do...Loops are done and I then try to display item(s) from the dictionary. I can not seem to get it to display one when I ask for it directly as I do in line 42 or looping through items (I receive the same error on line 47 when I remark line 42).

I have worked with dictionaries before and never had this problem. I even tried the following,

for Each Key in dictMemSplItems
response.write dictMemSplItems(key)

which has worked for me in other situations but does not now.



Old July 23rd, 2004, 08:09 PM
Friend of Wrox
Join Date: Sep 2003
Posts: 363
Thanks: 0
Thanked 1 Time in 1 Post


   can u point the line clearly which got error?

Old July 24th, 2004, 12:58 PM
Registered User
Join Date: Jul 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to andersoni

The line that receives the error is either of the following lines.

response.write "item = " & dictMemSplItems.item("item0") & "<br>"


Similar Threads
Thread Thread Starter Forum Replies Last Post
using dictionary object rajiv_software Classic ASP Basics 4 June 21st, 2005 02:53 PM
dictionary object with session scope lcsgeek Classic ASP Basics 1 May 3rd, 2005 09:48 AM
Exception object nazneen Java Espanol 1 October 7th, 2004 07:08 PM
sessions and the dictionary object lcsgeek Classic ASP Professional 1 January 27th, 2004 06:11 AM
PHP and ASP 'Dictionary Object' HammR Beginning PHP 5 December 6th, 2003 11:18 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.