- cannot manually edit applicationhost.config
- must declare the scalar variable
- classic asp and access not working on windows 2008 64bit
- asp.net page titles are blank
- sql to get totals for last six months
- white space being counted as a node
- cross page posting not working
- collection is read only exception
- PayPal sending incorrect carrier information
- paypal guest user notice
- classic asp dictionary not working
- IE8 not supporting innerHTML
- differences between jet and odbc
- sugarcrm not inserting email
- select random records from access
- button click event firing twice
- how to send an email using cdosys
- installing perl on win2003 64 bit
- asp.net page event order
- rewrite rule for subdomains only
- extra items in javascript array
- IE7 margin auto not working
- IE7 border style dotted glitch
- ByRef and ByVal in vbscript
- weather rss feed
- Classic asp crib sheet
- Firefox onsubmit image change
- limit records in access
- AccessDataSource is thick
- double margins in IE6
- extra image padding in html emails
- decimal places in linux flash player
- broken emails in outlook 2007
- double spaced IE list items
- cannot remove movieclip
articles:
classic asp dictionary not working
Found an interesting feature of the classic dictionary object. Consider this code block:
dim conn
dim rs
dim myDictionary
set conn = server.CreateObject("ADODB.connection")
conn.open connPublic
'connPublic is just a normal connection string
set rs = server.CreateObject("ADODB.recordset")
set myDictionary = Server.CreateObject("Scripting.Dictionary")
rs.open "SELECT [id],[pagename] FROM [maincontent]",conn,3
do while not rs.eof
myDictionary.add cstr(rs("id")), rs("pagename")
rs.movenext
loop
rs.close
set rs = nothing
conn.close
set conn = nothing
dim i
for each i in myDictionary
response.write(myDictionary.item(i) & "<br>")
next
set myDictionary = nothing
This seemingly plausible block of code returns the highly descriptive error '80020009'.
It appears that this error is due to the dictionary add method not really doing what it says on the tin, i.e. not adding. Fortunately there is a work around for this problem - change
myDictionary.add cstr(rs("id")), rs("pagename")
for
myDictionary(cstr(rs("id"))) = rs("pagename")
Doing this forces the dictionary object to create a new item with the name you have specified, much like what you would expect the 'add' method to do...
Post a comment
