日期:2014-05-17  浏览次数:20443 次

希望有才的人帮我解释一下这段代码!不怎么看得懂,谢谢!
希望有才的人帮我解释一下这段代码!不怎么理解?
<%'添加产品If NOT IsEmpty (request("AddProSubmit")) then 
dim productdate,discount 
discount=round(request("price2")/request("price1"),2) 
if request("productdateyear")<>"" then 
 productdate=trim(request("productdateyear"))&"年"&trim(request("productdatemonth"))&"月" 
else  productdate="" 
end if  
set rs=server.CreateObject("adodb.recordset") rs.Open "select * from product",conn,1,3 rs.AddNew 
 rs("productdate")=productdate  rs("discount")=discount
   rs("name")=trim(request("name"))  
 rs("format")=request("format")  
if request("pagenum")<>"" then  rs("pagenum")=int(request("pagenum")) 
else  rs("pagenum")=0 
end if 
 if request("printed")<>"" then 
 rs("printed")=int(request("printed")
 else rs("printed")=0
 end if 
rs("author")=trim(request("author"))
  rs("mark")=trim(request("mark")) 
rs("introduce")=trim(request("introduce")) 
  rs("price1")=trim(request("price1"))
   rs("price2")=trim(request("price2"))  
 rs("vipprice")=trim(request("vipprice"))  
  rs("pic")=trim(request("pic")) 
 rs("categoryid")=int(request("categoryid")) rs("sortsid")=int(request("sortsid")) 
  rs("score")=request("score")  
 rs("type")=trim(request("type")) 
 rs("solded")=0  rs("viewnum")=0  
rs("adddate")=now()  rs("rank")=0 
  rs("ranknum")=0 if request("detail")<>"" then 
 rs("detail")=htmlencode2(request("detail")) end if 
if request("content")<>"" then 
 rs("content")=htmlencode2(request("content")) end if if request("detail")<>"" then  rs("desc")=htmlencode2(strvalue(request("detail") ,100))
 end if '是否推荐产品 
if request("recommend")=1 then   
 rs("recommend")=1 else 
 rs("recommend")=0 end if rs.Update rs.Close set rs=nothing call MsgBox("添加成功!","GoUrl","addpro.asp") response.Endend if%>http://bbs.csdn.net/topics/

------解决方案--------------------
挺怀旧的代码啊,都好些年木碰这东西

这是asp代码,vbscript脚本写滴
代码比较多,不同好一句一句翻译,只翻译关键的玩意把

discount=round(request("price2")/request("price1"),2) round是四舍五入

set rs=server.CreateObject("adodb.recordset") 申明一个记录集对象
rs.Open "select * from product",conn,1,3  根据sql获取相关记录集
rs.AddNew 在记录集里新增一记录
后面那一串的东西是给这条新增记录赋值

rs.Update 将上面新增那条记录更新入库
 rs.Close 关闭记录集
 set rs=nothing  释放记录集对象
call MsgBox("添加成功!","GoUrl","addpro.asp")调用一个自己写的函数 弹出成功消息
 response.End 输出结束

------解决方案--------------------
话说受博客园的影响,很多人把什么旧语言,新语言区分的很严重

实际上木那么严重了,看到这种10年前的古董代码,你们觉着他和你现在用datatable,adapter有多大区别?很像把?看到action和一堆request("content")你们觉着,他和已经被博客园神话了滴asp.net mvc里的action,request,viewdate,viewbag像不像? 
------解决方案--------------------
不难理解下呀,一句一句看就行了