极端幼稚的问题,好心人帮我看看这段asp代码,我受不了了 (50分)

Y

y1

Unregistered / Unconfirmed
GUEST, unregistred user!
<%
dim category,item_no,descp,caca
caca=trim(Request.QueryString("category"))
category=caca
if caca = "" then
category="tb"
if caca = "Toitery+Bags" then
category = "tb"
if caca = "Pouch" then
category = "po"
if caca = "Handbag" then
category = "hb"
if caca = "Portfolio" then
category = "pf"
if caca = "Zipper+Bags" then
category = "zb"
if caca = "Frame+Purze" then
category = "fp"
if caca = "Backpack" then
category= "bp"

if caca = "tb" then
caca = "Toitery Bags"
if caca = "po" then
caca = "Pouch"
if caca = "hb" then
caca = "Handbag"
if caca = "pf" then
caca = "Portfolio"
if caca = "zb" then
caca = "Zipper Bags"
if caca = "fp" then
caca = "Frame Purze"
if caca = "bp" then
caca = "Backpack"

pageno=Request.QueryString("pageno")
if not isnumeric(pageno) then
pageno=1
item_no=trim(Request.QueryString("item_no"))

descp=trim(Request.QueryString("descp"))

dbpath=server.mappath("product.mdb")
set conn=server.createobject("adodb.connection")
conn.open "Provider = Microsoft.Jet.OLEDB.4.0;
Data Source ="&amp;dbpath
set rs=server.createobject("adodb.recordset")
sqltext="select * from product where"
if category<>"" then
sqltext=sqltext &amp;
" category='"&amp;category&amp;"'"

if item_no<>"" then
sqltext=sqltext &amp;
" and itemno like %'"&amp;itemno&amp;"'%"

if descp<>"" then
sqltext=sqltext &amp;
" and description like %'"&amp;descp&amp;"'%"

sqltext=sqltext &amp;
"order by date desc"

rs.open sqltext,conn,1,1
rs.pagesize=6
if not(rs.eof) then

rs.absolutepage=pageno
end if
%>
 
楼上,我加了也不行,这样单行的应该可以不要end if呀
 
就是
只有最后一个if 有end if其他的都没有。
sqltext=sqltext &amp;
"order by date desc"
的order前面没有空格
 
单行出要end if
Request.QueryString("category"))也不对
 
Request.QueryString("category"))也不对
?????????????怎么不对
 
都加了end if 还不行
 
少了一个判断,你先判断是否为空
if Request.QueryString("category")=null then
caca=""
 
提交代码如下:
<form action="<%=Request.ServerVariables("script_name")%>" method=get>
<table><tr>
<td><B>ITEM_NO:</B></td><td><INPUT type="text" name="item_no" size=20></td>
<td><B>CATEGORY:</B></td><td>
<SELECT name="category">
<OPTION>Toitery Bags</OPTION>
<option>Pouch</option>
<Option>Handbag</option>
<option>Portfolio</option>
<option>Zipper Bags</option>
<option>Frame Purze</option>
<option>Backpack</option>
</SELECT></td></tr><tr><td>
 
全部加了以上朋友说的东西,还不行
 
sqltext="select * from product where"
if category<>"" then
sqltext=sqltext &amp;
" category='"&amp;category&amp;"'"

if item_no<>"" then
sqltext=sqltext &amp;
" and itemno like %'"&amp;itemno&amp;"'%"

if descp<>"" then
sqltext=sqltext &amp;
" and description like %'"&amp;descp&amp;"'%"

sqltext=sqltext &amp;
"order by date desc"
我觉着是SQL语句构造错误;假如三个变量都为空,语句不就成为这样了。
select * from product where order by date desc
这能对么?????
 
楼上,三个变量都不可能为空,问题出在对caca的判断那里
如果全部删除对caca的判断,是可以通过的
 
大佬 用什么if then
啊 用case吧
 
楼上,效果一样的,错误也一样
 
你把SQLTEXT那个变量打印出来看一下,分析一下SQL语句看有什么错误!
另:错误是什么?
 
看了sqltext
问题在于,条件语句根本就没有起作用
 
问题好象是,不能对提交过来的数据进行比较,如:category
 
是不是没有转成正确的数字类型进行比较
 
对空格好象不能识别,需换成加号才能通过,但也是不能比较
 
顶部