求解一段ASP代码(是购物车的)

<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#incl
ude file="manage/inc/config.asp"-->
<!--#include file="inc/conn.asp"-->
<!--#include file="inc/chk.asp"-->

<%
dim id,username,action
action=request.QueryString("action")
username=trim(request.cookies(cookieName)("username"))
id=request.QueryString("id")
set rs=server.CreateObject("adodb.recordset")
select case action
case "del"
conn.execute "delete from orders where actionid="&request.QueryString("actionid")
response.redirect "car.asp"
case "add"
rs.open "select id,username from orders where username='"&username&"' and id="&id&" and state=6",conn,1,1
if not rs.eof and not rs.bof then
call MsgBox("对不起,此商品已存在于您的购物车中,不可以重复添加!","Close","None")
response.end
rs.close
else
rs.close
rs.open "select id,username,state,paid from orders",conn,1,3
rs.addnew
rs("id")=id
rs("username")=username
rs("state")=6
rs("paid")=0
rs.update
rs.close
set rs=nothing
call MsgBox("商品成功添加到你的购物篮!","Close","None")
response.end
end if
end select

rs.open "select orders.actionid,orders.id,product.name,product.price1,product.price2,product.discount from product inner join orders on product.id=orders.id where orders.username='"&request.cookies(cookieName)("username")&"' and orders.state=6",conn,1,1
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>网上书店</title>
<link href="style.css" rel="stylesheet" type="text/css">

'rs.Open sql,conn,1,1无法看到其他用户添加的新数据,但被其他用户删除的数据将变为不可访问,同时可以看到其他用户所作的修改。

'rs.Open sql,conn,1,3静态打开方式。在你使用数据是其他用户无法访问该数据

'rs.Open sql,conn,1,2动态的数据库打开方式,其他用户所进行的修改、删除和新建等工作都会立即在数据对象中体现出来,并且支持全部类型的数据移动方式,除非提供者不支持,否则也可以进行书签操作

'rs.Open sql,conn,-1不指定打开方式

<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#incl
ude file="manage/inc/config.asp"-->
<!--#include file="inc/conn.asp"-->
<!--#include file="inc/chk.asp"-->

<%
dim id,username,action
action=request.QueryString("action") '取得前页面传来的参数action和id以及从cookies中去的用户名分别存入变量aciton,id,name中
username=trim(request.cookies(cookieName)("username"))
id=request.QueryString("id")
set rs=server.CreateObject("adodb.recordset") '建立数据库连接,创建一个recordset对象rs
select case action '以下分情况对action进行判断
case "del" '当为del时候,表示删除执行语句delete from orders where actionid=前页面的参数actionid
conn.execute "delete from orders where actionid="&request.QueryString("actionid")
response.redirect "car.asp" '然后页面跳转到car.asp这一页面
case "add" '当为add时候,表示增加。执行语句 select id,username from orders where username='"&username&"' and id="&id&" and state=6
rs.open "select id,username from orders where username='"&username&"' and id="&id&" and state=6",conn,1,1 '先检查购物车中是否已经存在这件货物,如果否,就添加到数据库
if not rs.eof and not rs.bof then '如果已经添加过了就弹出提示框 提示对不起,此商品已存在于您的购物车中,不可以重复添加
call MsgBox("对不起,此商品已存在于您的购物车中,不可以重复添加!","Close","None")
response.end
rs.close '关闭连接
else '当购物车中没有刚才要添加的记录的时候,进行添加
rs.close
rs.open "select id,username,state,paid from orders",conn,1,3
rs.addnew '添加一个新行,在recordset中
rs("id")=id '设置这一行各对应列的值
rs("username")=username
rs("state")=6
rs("paid")=0
rs.update '然后执行update操作将这一行插入到数据库中去
rs.close '关闭连接
set rs=nothing '清空对象,注意随时关闭连接和清空对象,否则很容易出错
call MsgBox("商品成功添加到你的购物篮!","Close","None") '弹出添加成功提示
response.end '返回
end if
end select
'选择此用户购物车里所有物品 ,可能要显示
rs.open "select orders.actionid,orders.id,product.name,product.price1,product.price2,product.discount from product inner join orders on product.id=orders.id where orders.username='"&request.cookies(cookieName)("username")&"' and orders.state=6",conn,1,1
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>网上书店</title>
<link href="style.css" rel="stylesheet" type="text/css">
温馨提示:答案为网友推荐,仅供参考
相似回答