ASP Dictionary Object Usage _ application Skills

Source: Internet
Author: User
If saving a Dictionary object at the session level lowers the performance of the system, and saving a Dictionary object at the application level can cause the Web server to crash, that's not much to say.
Now we want to consider the dictionary objects in a single page, what are the design defects:
We can try that.
Set Rs=server.createobject ("Adodb.recordset")
Sql= "SELECT * FROM table"
Rs.Open sql,conn,1,3
Set Ttt=server.createobject ("Scripting.Dictionary")
Ttt.add "xxx", rs ("field")
Set rs=nothing
LIU=TTT ("xxx") ' What will you find when you do this? The ASP page will tell you that an accident occurred!!! This is very surprising, what is an accident? Hard to say, then after my repeated tests found that the value of Rs ("field") can not be directly given to the Dictionary object, after repeated research concluded that: Dictionry is the RS ("field") memory address to store, so that, The one I wrote just now is a disaster, the solution is to put this RS ("field") into a variable can be solved, but Dictionary object can not save A is not the object? This is a big question, so I wrote a program, we can save into try.htm to see the effect of
<script language= ' VBScript ' >
Set Ttt=createobject ("Scripting.Dictionary")
Ttt.add "Liu", "UUU"
Set Ddd=createobject ("Scripting.Dictionary")
Ddd.add "PPP", TTT
Set ttt=nothing
BBB=DDD ("PPP") ("Liu")
Alert (BBB)
</script>
What was the result? You'll find an alert. UUU description is no problem, which means that the Dictionary object is actually putting another
Dictionary object The entire clone came in, which is more validated by Wrox's book, Dictionary object in MS Development when its
It's for the client, that's the argument.
We also have the same code that we can share with dictionary.
<script language= ' VBScript ' >
I=1
Picname= ("xxx")
Str= "Set" & "Pic_" & I & "=createobject (" & "" "" & "Scripting.Dictionary" & "" "&") "
Execute (STR)
Str= "Pic_" & I & ". Add" & "" "&" Picname "&" "" & "," & "" "" & Picname & "" ""
Execute (STR)
Dim ttt ()
ReDim TTT (5)
TTT (0) = "UUU"
Pic_1.add "Item", TTT
Liu=pic_1 ("Picname")
Set Pic_2=createobject ("Scripting.Dictionary")
Erase TTT
ReDim TTT (5)
TTT (0) = "III"
Nnn=pic_1 ("item") (0)
Pic_2.add "RRR", TTT
Zzz=pic_2 ("RRR") (0)
Alert (Liu)
Alert (NNN)
Alert (ZZZ)
</script>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.