<% dim cartid,id,name,price,quantity cartid=session("cartid") if cartid=""then cartid=0 id=request("id1") name=request("name1") price=CCur(request("price1")) quantity=1
set rscart=server.createobject("adodb.recordset") sql="select*from carts where cartid="&cartid rscart.open aql,conn,3,2
if rscart.eof then rscart.addnew rsCart("cartdate")=date() rscart.update rscart.movelast cartid=rscart("cartid") session("cartid")=cartid end if rscart.close set rscart=nothing sql="insert into cartitems(cartid,productid,name,price,quantity) values("&cartid&","&id&",`"&name&"`,"&price&","&quantity&")" conn.execute sql set conn=nothing
if rscart.eof then 这个错误,改为if not rscart.bof then rscart.addnew 用了这个那么必须加一个rscart.update匹配才是添加 rsCart("cartdate")=date() rscart.update rscart.movelast cartid=rscart("cartid") session("cartid")=cartid rscart.update end if
你是要排除存在的 if rscart.eof then 最好改为if rscart.bof then rscart.addnew 用了这个那么必须加一个rscart.update匹配才是添加 rsCart("cartdate")=date() rscart.update rscart.movelast cartid=rscart("cartid") session("cartid")=cartid rscart.update end if
倒,没注意 if rscart.eof then 最好改为if rscart.bof then rscart.addnew rsCart("cartdate")=date() rscart.update rscart.movelast //这个删掉 cartid=rscart.fields("cartid") 使用rscart.fields就可以获取刚刚插入的cartid号 session("cartid")=cartid end if
我不明白cartid你这个是自动编号吗?? sql="select*from carts where cartid="&cartid 如果不是自动编号,你
if rscart.eof then 最好改为if rscart.bof then rscart.addnew rsCart("cartdate")=date() rscart.update rscart.movelast //这个删掉 cartid=rscart.fields("cartid") 使用rscart.fields就可以获取刚刚插入的cartid号 session("cartid")=cartid end if 这个怎么写入cartid的值?没有写入那不就是空的吗? 我晕你啊!!你到底再干吗哦! 写的乱七八糟,我都看蒙了
恩改了,这个是现在的代码。 还是出现一样的调试错误, Microsoft VBScript 编译器错误 (0x800A0409) 未结束的字符串常量 line 25, column 64 sql="insert into cartitems(cartid,productid,name,price,quantity) 提示是是上面那句错误
<% dim cartid,id,name,price,quantity cartid=session("cartid") if cartid=""then cartid=0 id=request("id1") name=request("name1") price=CCur(request("price1")) quantity=1
set rscart=server.createobject("adodb.recordset") sql="select*from carts where cartid="&cartid rscart.open sql,conn,3,2
if rscart.eof then rscart.addnew rsCart("cartdate")=date() rscart.update rscart.movelast cartid=rscart("cartid") session("cartid")=cartid end if rscart.close set rscart=nothing sql="insert into cartitems(cartid,productid,name,price,quantity) values("&cartid&","&id&",'"&name&"',"&price&","&quantity&")" conn.execute sql set conn=nothing
你把sql="insert into cartitems(cartid,productid,name,price,quantity) values("&cartid&","&id&",'"&name&"',"&price&","&quantity&")" 输出来试试,可能有引号之类的字符没有过滤!!!!
'""' 是外面一个单引号 里面一个双引号没错吧 <% dim cartid,id,name,price,quantity cartid=session("cartid") if cartid=""then cartid=0 id=request("id1") name=request("name1") price=CCur(request("price1")) quantity=1
set rscart=server.createobject("adodb.recordset") sql="select*from carts where cartid="&cartid rscart.open sql,conn,3,2
if rscart.eof then rscart.addnew rsCart("cartdate")=date() rscart.update rscart.movelast cartid=rscart("cartid") session("cartid")=cartid end if rscart.close set rscart=nothing
sql="insert into cartitems(cartid,productid,name,price,quantity) values("&cartid&","&id&",'"&name&"',"&price&","&quantity&")" conn.execute sql set conn=nothing