scripting.Dictionary Objects

R

Robin

Can anyone point me in a good direction to get more info on
scripting.dictionary objects?

Or, maybe someone can see what's wrong with my code ...
I ran this without setting the 'd' to a variable and it worked fine. So I
know it has something to do with the way I'm naming them.

Error I'm getting is on the d.add line and it is:
Error Type:
Microsoft VBScript runtime (0x800A01A8)
Object required: 'd4'

This is the code:

set rsUnique = conn.execute("Select DISTINCT ownerID from Sites Where
customerID =" &session("ID") & " order by ownerID")
while not rsUnique.EOF
dim d
d = "d" & rsUnique("OwnerID")
set d = server.createObject ("Scripting.Dictionary")
rsUnique.MoveNext
wEnd

'*** SCRIPTING DICTIONARY ***
set rsBlah = conn.execute("Select * from Sites where customerID = " &
session("ID") & " order by ownerID, siteID")
dim rsID,rsName
while not rsBlah.EOF
If rsBlah("ownerID") <> x Then
d = "d" & rsBlah("ownerID")
End If
i = i + 1
rsID = rsBlah("ID")
rsName = rsBlah("Name")
rsname2 = rsBlah("OID")
d.Add rsID, rsName&","&rsname2 'THIS IS THE LINE THAT IS STOPPING AT
a = d.Items
b = d.keys
rsBlah.moveNext
wEnd
response.write d.count & "<BR>"
i = 0
for i = 0 to d.count -1
s = s & b(i) & a(i) & "<BR>"
next
response.write s
response.write "done<br>"
 
R

Ray at

Robin said:
Can anyone point me in a good direction to get more info on
scripting.dictionary objects?
http://msdn.microsoft.com/library/en-us/script56/html/jsobjDictionary.asp



Or, maybe someone can see what's wrong with my code ...

Error I'm getting is on the d.add line and it is:
Error Type:
Microsoft VBScript runtime (0x800A01A8)
Object required: 'd4'

Are you sure this is the right code snippet? I don't see anything trying to
use an objet named "d4."

This is the code:

set rsUnique = conn.execute("Select DISTINCT ownerID from Sites Where
customerID =" &session("ID") & " order by ownerID")
while not rsUnique.EOF
dim d

You should DIM outside of loops.
d = "d" & rsUnique("OwnerID")
set d = server.createObject ("Scripting.Dictionary")

Okay, so which is it? d is d & rsUnique("ownerid") or d is a dictionary
object? It can't be both. In this case, it will be the dictionary object.

rsUnique.MoveNext
wEnd

You're creating a dictionary object over and over again in a loop!




'*** SCRIPTING DICTIONARY ***
set rsBlah = conn.execute("Select * from Sites where customerID = " &
session("ID") & " order by ownerID, siteID")
dim rsID,rsName
while not rsBlah.EOF
If rsBlah("ownerID") <> x Then
d = "d" & rsBlah("ownerID")
End If
i = i + 1
rsID = rsBlah("ID")
rsName = rsBlah("Name")
rsname2 = rsBlah("OID")
d.Add rsID, rsName&","&rsname2 'THIS IS THE LINE THAT IS STOPPING AT


Again, d can't be many things. Now, d is "d" & rsBlah("OwnerID"), NOT a
dictionary object. Are you trying to create a whole bunch of dictionary
objects? What are you trying to do here? You're giving d all these
different values all over the place.

Try using meaningful variable names, even if they seem silly at the time.
And don't try to use the same variable for multiple things [at the same
time].

Dim theDictionaryObject, theOwnerID

Ray at work
 
R

Robin

Sorry the code looks so confusing ... What I was trying to do was set d to
equal "d" and the ownerID (i.e. d18, d65 etc...). Then to define each of
these as a scripting.dictionary and grab all of the sites that fall under
that ownerID into that scripting.dictionary.
Hence why I had d defined a few times and why it was looping. I did get it
to work. I moved my loop on rsUnique to the very end of the code.
Now I just have to figure out how to call on those objects.

-r

Ray at said:
Robin said:
Can anyone point me in a good direction to get more info on
scripting.dictionary objects?
http://msdn.microsoft.com/library/en-us/script56/html/jsobjDictionary.asp



Or, maybe someone can see what's wrong with my code ...

Error I'm getting is on the d.add line and it is:
Error Type:
Microsoft VBScript runtime (0x800A01A8)
Object required: 'd4'

Are you sure this is the right code snippet? I don't see anything trying to
use an objet named "d4."

This is the code:

set rsUnique = conn.execute("Select DISTINCT ownerID from Sites Where
customerID =" &session("ID") & " order by ownerID")
while not rsUnique.EOF
dim d

You should DIM outside of loops.
d = "d" & rsUnique("OwnerID")
set d = server.createObject ("Scripting.Dictionary")

Okay, so which is it? d is d & rsUnique("ownerid") or d is a dictionary
object? It can't be both. In this case, it will be the dictionary object.
rsUnique.MoveNext
wEnd

You're creating a dictionary object over and over again in a loop!




'*** SCRIPTING DICTIONARY ***
set rsBlah = conn.execute("Select * from Sites where customerID = " &
session("ID") & " order by ownerID, siteID")
dim rsID,rsName
while not rsBlah.EOF
If rsBlah("ownerID") <> x Then
d = "d" & rsBlah("ownerID")
End If
i = i + 1
rsID = rsBlah("ID")
rsName = rsBlah("Name")
rsname2 = rsBlah("OID")
d.Add rsID, rsName&","&rsname2 'THIS IS THE LINE THAT IS STOPPING
AT


Again, d can't be many things. Now, d is "d" & rsBlah("OwnerID"), NOT a
dictionary object. Are you trying to create a whole bunch of dictionary
objects? What are you trying to do here? You're giving d all these
different values all over the place.

Try using meaningful variable names, even if they seem silly at the time.
And don't try to use the same variable for multiple things [at the same
time].

Dim theDictionaryObject, theOwnerID

Ray at work
 
R

Ray at

You can't do what you were trying to do...*

I'm sure that you can do everything that you're trying to do by using just
ONE query with a JOIN.


Ray at work

* This isn't entirely true, as you can always use the "execute" command to
execute commands contained as a string value, but this is HORRIBLE coding
practice, imo.



Robin said:
Sorry the code looks so confusing ... What I was trying to do was set d to
equal "d" and the ownerID (i.e. d18, d65 etc...). Then to define each of
these as a scripting.dictionary and grab all of the sites that fall under
that ownerID into that scripting.dictionary.
Hence why I had d defined a few times and why it was looping. I did get it
to work. I moved my loop on rsUnique to the very end of the code.
Now I just have to figure out how to call on those objects.

-r

Ray at said:
http://msdn.microsoft.com/library/en-us/script56/html/jsobjDictionary.asp



Are you sure this is the right code snippet? I don't see anything
trying
to
use an objet named "d4."



You should DIM outside of loops.


Okay, so which is it? d is d & rsUnique("ownerid") or d is a dictionary
object? It can't be both. In this case, it will be the dictionary object.

You're creating a dictionary object over and over again in a loop!
STOPPING
AT


Again, d can't be many things. Now, d is "d" & rsBlah("OwnerID"), NOT a
dictionary object. Are you trying to create a whole bunch of dictionary
objects? What are you trying to do here? You're giving d all these
different values all over the place.

Try using meaningful variable names, even if they seem silly at the time.
And don't try to use the same variable for multiple things [at the same
time].

Dim theDictionaryObject, theOwnerID

Ray at work
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top