首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > ASP >

换了个页面就获取不了SESSION的值解决思路

2012-06-15 
换了个页面就获取不了SESSION的值学习途中,做到订单系统哪方面,购物车,订单都已经建立完成。但是我在用户中

换了个页面就获取不了SESSION的值
学习途中,做到订单系统哪方面,购物车,订单都已经建立完成。
但是我在用户中心那里添加一个查询购物车的页面,就获取不了SESSION的值,不知道为甚么
代码基本跟购物车的一样,购物车都能获取,不知道为甚么换了个页面就获取不了

HTML code
<%sub addtocart() ProductList = Session("ProductList")Products = Split(Request("Prodid"), ",")For I=0 To UBound(Products)   PutToShopBag Products(I), ProductListNextSession("ProductList") = ProductListif request("payment")="去收银台" thenresponse.redirect "b2b_ddlcsys.asp?action=1"end ifIf Request("cmdShow") = "Yes" Then   ProductList = ""   Products = Split(Request("ProdId"), ", ")   For I=0 To UBound(Products)      PutToShopBag Products(I), ProductList   Next   Session("ProductList") = ProductListEnd IfIf Len(Session("ProductList")) = 0 Thenend if%><%Set rsCheck=Server.CreateObject("ADODB.RecordSet") strsql="select id,name,price,amount,stock from Product where ID in ("&Session("ProductList")&") order by ID"rsCheck.open strsql,conn,1,1%><link href="b2b_includefile/css.css" rel="stylesheet" type="text/css"><table width="96%" border="0" cellspacing="0" cellpadding="0" align="center"><tr> <form action="check.asp" method="POST" name="check"><td>      <table border="0" cellspacing="1" cellpadding="4" align="center" width="100%" bgcolor="#f2f2f2">            <tr bgcolor="#f7f7f7" height="25" align="center">             <td width="40"><strong>编 号</strong></td>            <td width="300"><strong>商 品 名 称</strong></td>            <td width="40"><strong>数量</strong></td>            <td width="60"><strong>成交价</strong></td>            <td width="70"><strong>总 计</strong></td>          </tr><%Sum = 0Quatity = 1Do While Not rsCheck.EOF     Quatity = CInt( Request.Form( "Q_" & rsCheck("ID")) )     If Quatity <= 0 Then         Quatity = CInt( Session(rsCheck("ID")) )        If Quatity <= 0 Then Quatity = 1     End IfSession(rsCheck("ID")) = QuatityIF rsCheck("Stock") < Quatity ThenQuatity = 1Session(rsCheck("ID")) = 1response.write "<script language=javascript>alert('对不起,"&rsCheck("Name")&"暂时库存不足!');window.close();</script>" Response.End()Conn.CloseSet Conn = NothingEnd IFDim PricePrice =  Round(rsCheck("Price"),2)Sum = Sum + price*QuatitySum=Round(Sum,2) %> 



最后25分,散出去啦

Microsoft OLE DB Provider for SQL Server (0x80040E14)
第 1 行: ')' 附近有语法错误。
/网站5/disuser.asp, 第 33 行

也就是
Set rsCheck=Server.CreateObject("ADODB.RecordSet") 
strsql="select id,name,price,amount,stock from Product where ID in ("&Session("ProductList")&") order by ID"
rsCheck.open strsql,conn,1,1


经过输出测试,发觉("&Session("ProductList")&") 没有值

可是就不知道那里错了,高人指点下。。

石头大哥啊!!!

[解决办法]
<%
sub addtocart() 

ProductList = Session("ProductList")
Products = Split(Request("Prodid"), ",")
For I=0 To UBound(Products)
PutToShopBag Products(I), ProductList
Next
Session("ProductList") = ProductList

if request("payment")="去收银台" then


response.redirect "b2b_ddlcsys.asp?action=1"
end if

If Request("cmdShow") = "Yes" Then
ProductList = ""
Products = Split(Request("ProdId"), ", ")
For I=0 To UBound(Products)
PutToShopBag Products(I), ProductList
Next
Session("ProductList") = ProductList
End If
If Len(Session("ProductList")) = 0 Then
end if
%>
分别在红色的后面输出Session("ProductList") 看看有没有值
[解决办法]

VBScript code
ProductList = Session("ProductList")Products = Split(Request("Prodid"), ",")For I=0 To UBound(Products)   PutToShopBag Products(I), ProductListNextSession("ProductList") = ProductListif request("payment")="去收银台" thenresponse.redirect "b2b_ddlcsys.asp?action=1"end ifIf Request("cmdShow") = "Yes" Then   ProductList = ""   Products = Split(Request("ProdId"), ", ")   For I=0 To UBound(Products)      PutToShopBag Products(I), ProductList   Next   Session("ProductList") = ProductListEnd If
[解决办法]
用户登录就应该赋予SESSION的值

如:
Session("ProductList")=rs("username")


然后在其他页直接获取SESSION的值就可以了
如:
ProductList = Session("ProductList")


判断SESSION的值
<%
if Session("ProductList")="" then
Response.Redirect "../"
Response.End
end if
%>

热点排行