asp中字符串转化为实体类的方法(提高篇,自动方法)
书接上文,直接从字符串返回对象,此次更新,实现了返回对象的自动化,无需在声明实体类。但这个函数只适合页面声明几个对象,批量对象,比如几百个,推荐使用下一文所使用函数。
函数很简单,不解释,直接贴代码。
option explicit
'返回对象的函数
function getObj(byval str)
dim classname,itemlist,i
classname = split(str,"|||")(0)
dim execstr
execstr = "class "&classname&chr(10)
itemlist = split(split(str,"|||")(1),",")
for i = 0 to ubound(itemlist)
execstr = execstr +"public "&split(itemlist(i),":")(0)&chr(13)&chr(10)
next
execstr = execstr + "Private Sub Class_Initialize"&chr(13)&chr(10)
for i = 0 to ubound(itemlist)
execstr = execstr +split(itemlist(i),":")(0)&" = """&split(itemlist(i),":")(1)&"""" &chr(13)&chr(10)
next
execstr = execstr&"end sub"&chr(13)&chr(10)&_
"end class"&chr(13)&chr(10)&_
" set getobj = new "&classname
execute execstr
end function
'测试部分
dim str1
str1 ="order|||shiyang:100,mayang:200"
sub ceshi2
dim i,o1
for i = 0 to 10000
set o1 = getObj(str1)
response.write o1.shiyang&"<br>"
next
end sub
dim t1
t1=timer()
call ceshi2
response.write FormatNumber((timer()-t1),4,-1)
下期更精彩!!!!
相关文档:
<%
If Not IsNull(Request("fileName")) Then r = DownLoadFile(Request("fileName"))
Function DownLoadFile(fileName)
Dim s,fso,f,fLen
fileName = Server.MapPath(fileName)
'create stream
Set s = Server.CreateObject("ADODB.Stream")
s.Open()
s.Type = 1
Set fso = Server.CreateObject ......
用ASP实现支持附件的EMail系统(2)
不过这仅仅只是得到了发送者的ip地址和mac地址,而且禁止用户自己更改自己ip地址的代码,因为我们的系统是需要对个人修改ip的行为进行禁止的。
<%
strIP = Request.ServerVariables("REMOTE_ADDR")
Set net = Server.CreateObject("wscript.network")
Set sh = S ......
用ASP实现支持附件的EMail系统(3)
尝试发送邮件,但是失败了,请修改错误后重试!
<script language="javascript">
alert("您输入的收件组格式错误!\r正确的格式是:'gr:001'");
history.back();
</script>
<p>
<%
response.end
else
thegroup=(mid(trim(strfieldvalue),4))
end if
......
后台数据库:
[Microsoft Access]
与
[Microsoft Sql Server]
更换之后,ASP代码应注意要修改的一些地方:
[一]连接问题(举例)
[Microsoft Access]
constr = "DBQ=c:\data\clwz.mdb; DRIVER={Microsoft Access Driver (*.mdb)}"
[Microsoft Sql Server]
constr = "DRIVER={SQL Server};SERVER=host;DATA ......
目前在Internet上广泛使用的后台技术种类繁多,应用比较广泛的有CGI,ASP,PHP,JSP/JavaServlet,ColdFusion等。在这一节里,主要介绍几种在国内应用比较广泛的后台语言。
CGI,全称为Common Gateway Interface
CGI就是公共网关接口 (Common Gateway Interface) 的缩写。它是最早被用来建立动态网站的后台技术 ......