request and session question! thanks

99percent 2003-01-28 05:33:51
Set rstobj = Server.CreateObject ("ADODB.Recordset")
if request("t0")<>"0" and request("t1")<>"" and request("t2")<>"" and request("t3")<>"" then
session("t0")=request("t0")
session("t1")=request("t1")
session("t2")=request("t2")
session("t3")=request("t3")
abc="select * from produce_brand where(producesort='"& session("t0")&"' and 规格 like '%" & Trim(session("t2")) & "%' and 颜色 like '%" & Trim(session("t3")) & "%' and brand like '%" & Trim(session("t1")) & "%')"
end if
if request("t0")<>"0" and request("t1")="" and request("t2")<>"" and request("t3")="" then
session("t0")=request("t0")
session("t2")=request("t2")
abc="select * from produce_brand where producesort='"& session("t0")&"' and 规格 like '%" & Trim(session("t2")) & "%') "
end if
rstobj.open abc,cnndb,3,1
为什么不行啊?
如果我将最后的if条件部分全删除就行如果不是的话rstobj.open abc,cnndb,3,1话有问题搞了很久请教。
如果不用这种方法那么我用or来表示这两种条件怎么联起来?
先谢。
...全文
62 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
iperfect 2003-01-29
  • 打赏
  • 举报
回复
Set rstobj = Server.CreateObject ("ADODB.Recordset")
if request("t0")<>"0" and request("t1")<>"" and request("t2")<>"" and request("t3")<>"" then
session("t0")=request("t0")
session("t1")=request("t1")
session("t2")=request("t2")
session("t3")=request("t3")
abc="select * from produce_brand where(producesort='"& session("t0")&"' and 规格 like '%" & Trim(session("t2")) & "%' and 颜色 like '%" & Trim(session("t3")) & "%' and brand like '%" & Trim(session("t1")) & "%')"
rstobj.open abc,cnndb,3,1
elseif request("t0")<>"0" and request("t1")="" and request("t2")<>"" and request("t3")="" then
session("t0")=request("t0")
session("t2")=request("t2")
abc="select * from produce_brand where producesort='"& session("t0")&"' and 规格 like '%" & Trim(session("t2")) & "%') "
rstobj.open abc,cnndb,3,1
else
response.write abc
response.end
end if
iperfect 2003-01-29
  • 打赏
  • 举报
回复
Set rstobj = Server.CreateObject ("ADODB.Recordset")
if request("t0")<>"0" and request("t1")<>"" and request("t2")<>"" and request("t3")<>"" then
session("t0")=request("t0")
session("t1")=request("t1")
session("t2")=request("t2")
session("t3")=request("t3")
abc="select * from produce_brand where producesort='"& session("t0")&"' and 规格 like '%" & Trim(session("t2")) & "%' and 颜色 like '%" & Trim(session("t3")) & "%' and brand like '%" & Trim(session("t1")) & "%'"
rstobj.open abc,cnndb,3,1
end if
你试试这样行不行!
99percent 2003-01-29
  • 打赏
  • 举报
回复
Set rstobj = Server.CreateObject ("ADODB.Recordset")
if request("t0")<>"0" and request("t1")<>"" and request("t2")<>"" and request("t3")<>"" then
session("t0")=request("t0")
session("t1")=request("t1")
session("t2")=request("t2")
session("t3")=request("t3")
abc="select * from produce_brand where producesort='"& session("t0")&"' and 规格 like '%" & Trim(session("t2")) & "%' and 颜色 like '%" & Trim(session("t3")) & "%' and brand like '%" & Trim(session("t1")) & "%'"
response.write abc
response.end
end if
if request("t0")<>"0" and request("t1")="" and request("t2")<>"" and request("t3")="" then
session("t0")=request("t0")
session("t2")=request("t2")
abc="select * from produce_brand where producesort='"& session("t0")&"' and 规格 like '%" & Trim(session("t2")) & "%') "
response.write abc
response.end
end if
------------------------------------------------------
每一句都能response.write出来

如果我去掉了
response.write abc
response.end
它说:

rstobj.open abc,cnndb,3,1
出错
why???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????/>
laughingrat 2003-01-29
  • 打赏
  • 举报
回复
将你的request("t0")、request("t1")、request("t2")、request("t3")和
sql都用response.write写出来,看一下是否符合。

另外可以用trim()将空格去掉。
99percent 2003-01-29
  • 打赏
  • 举报
回复
abc="select * from produce_brand where producesort='"& session("t0")&"' and 规格 like '%" & Trim(session("t2")) & "%'"
这句我多了一边括号现在省去也是这样。
99percent 2003-01-28
  • 打赏
  • 举报
回复
哦好象都有错啊。
那怎么改啊?
flyinweb 2003-01-28
  • 打赏
  • 举报
回复
同意楼上的,跟踪一下SQL语句,看有无错误
99percent 2003-01-28
  • 打赏
  • 举报
回复
who can help me look about!!!
arclala 2003-01-28
  • 打赏
  • 举报
回复
abc="select * from produce_brand where (producesort='"& session("t0")&"' and 规格 like '%" & Trim(session("t2")) & "%') "

你最好将你的sql语句response.write 出来看看

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧