Need some help while my hair is still (mostly) intact. I've isolated this code out of a larger file (which i'm developing at the moment).
Code is as follows:
<!--#include file="dbconfile.asp"-->
<%
set Rs=server.createobject("adodb.recordset")
set cratedict=server.createobject("scripting.dictionary")
Rs.open "select top 5 bindtype, rate from current_rates where type='sp' and identifier=2051 order by bindtype",DatabaseConnection
while not Rs.eof
response.write replace(trim(Rs("bindtype")),"_","")&" - "&trim(Rs("rate"))&"<br>"
cratedict.add replace(trim(Rs("bindtype")),"_",""),Rs("rate")
Why would it give me the count on line 14, but not return the value on line 15?
Now, the thing is, i'm using dictonary objects in other scripts with no errors, and i can't for the life of me figure out what's going on.
no further responses needed, it turns out that my rate value needed to be trimmed. all is good, except for the state of my hair, but i can probably find most of it and paste it back on.
I also ran into this, and spent way too long trying to figure it out.
For future visitors to this thread:
It turns out that the two parameters passed to the scripting.dictionary "add" function are BYREFerence and not BYVALue, so it doesn't make a copy of the adodb.recordset data, but rather just puts a pointer to the adodb.recordset data. Of course, then you get finished with the rs (or move to the next record!) the dictionary.item() pointer goes to the wrong place, and then the adodb error.
So run your parameters through any function (trim, int) or assign them to a variable ( a=rs(0) : b=rs(0) : odict.add a,b ) and you won't get the weird errors, or pull out any hair!
Bookmarks