asp中字符串转化为实体类的方法(入门篇,传统方法)
此文只是入门,演示了如何用实体类存储数据,无实际意义。后面有陆续更新优化。(以后的文章中将陆续实现无需声明具体类自动存储数据,和简单的性能优化)
在asp程序开发过程中,结构数据的存储一直是个问题,asp的数组一直很弱,而且不能自解释,下面提供一种类似json格式的解释方法,以供大家参考。
我们假设我们想存储一张订单,实洋180元,码洋200元。声明字符串如下:
dim str1 : str1 = "order|||shiyang:180,mayang:200"
为了存储数据我们需要声明一个实体类,如下:
class order
public shiyang,mayang
end class
建立一个getobject函数为实体类赋值,如下:
function getObject(byval str)
dim itemlist,execstr
execstr = ""
set getObject = new order
itemlist = split(split(str,"|||")(1),",")
for i = 0 to ubound(itemlist)
execstr = execstr +"getObject."&split(itemlist(i),":")(0)&" = """&split(itemlist(i),":")(1)&"""" &chr(10)&chr(13)
next
execute execstr
end function
写一个测试函数 ,输出结果并测试效率
sub ceshi1
dim i
for i = 0 to 10000
set o1 = getObject(str1)
response.write o1.shiyang&"<br/>"
next
end sub
dim t1
t1=timer()
call ceshi1
response.write FormatNumber((timer()-t1),4,-1)
测试结果:生成10000个订单对象大概需要1秒钟左右时间。
本文无实际意义,只为开篇做引
相关文档:
第一节:注册系统
注册几乎是每个网站都要使用的,去论坛要注册,聊天要注册,几乎无处不注册,所以注册是所有ASP应用程序中最常见的。
& ......
用ASP实现支持附件的EMail系统(2)
不过这仅仅只是得到了发送者的ip地址和mac地址,而且禁止用户自己更改自己ip地址的代码,因为我们的系统是需要对个人修改ip的行为进行禁止的。
<%
strIP = Request.ServerVariables("REMOTE_ADDR")
Set net = Server.CreateObject("wscript.network")
Set sh = S ......
<bgsound src="wen.mid" loop="0">
<% dim weh
If Time >=#1:00:00 AM# And Time < #6:00:00 PM# Then
weh = "<bgsound src="1.mid" loop="0">"
Else If Time >#6:00:00 AM# And Time < #9:00:00 PM#
weh = "<bgso ......
Windows7下IIS7的安装及ASP配置方法★
本文讲述了在Windows 7下如何安装IIS7,以及IIS7在安装过程中的一些需要注意的设置,以及在IIS7下配置ASP的正确方法。转载过程中不得以任何方式和方法用于商业用途,请注明出处。谢谢您的支持。祝您安装及调试成功。
注:本人安装的是Windows 7 RC 7100 32位中文旗舰版 。
在Window ......