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

如果在SQLTEXT没什么问题,
那你把这句话拷到数据库程序那执行一下,
看有没有结果

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"
这几句写的不专业,至少没有容错能力
 
goodpb1
可能是的,全部是字符类型的,没有进行任何转换的操作,怎么转换????
 
dhl2001
我以前几乎没有用过asp,请原谅
不是sql语句的问题,是条件语句不能正确判断
 
if
then
endif
不确切的一招
按如下格式写能不能用,
ASP这个东西,什么怪事都会出的
 
楼上,我这样写过,也是不行
换成case,也是一样,就是条件比较那里的问题
 
各位同情同情我,我快死了
 
///////////
select case caca
case " "
category="tb"
caca "Toitery+Bags"
category = "tb"
caca "Pouch"
category = "po"
caca "Handbag"
category = "hb"
...................
End select
Pageno = request("pageno")
if not isnull(pageno) then
pageno = 1
........................
sqltext="select * from product where"
if category<>"" then
sqltext=sqltext &amp;
" category='"&amp;category&amp;"'"

if item_no<>"" then
sqltext=sqltext &amp;
" itemno like %'"&amp;itemno&amp;"'%"
(where 语句出错! 原:select * from product where and itemno like %'"&amp;itemno&amp;"'%"
WHERE 条件为空, WHERE不用时你要删除!)
if descp<>"" then
sqltext=sqltext &amp;
" description like %'"&amp;descp&amp;"'%"

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

end if
太长的,没时间看,也不清楚你什么地方出错,要对症下药!
 
楼上,查询条件为空的可能不存在,我手工排除了这个可能,问题依旧
 
你应该首先告诉大家哪里报错?报的什么错误?这样才能对症下药
另外我看了你在构造sql语句时好象不太好,
description like %'"&amp;descp&amp;"'%" 是不是应该把%放在引号里面呢
sqltext=sqltext &amp;
"order by date desc" 是不是应该改为:
sqltext=sqltext &amp;
" order by date desc"
if not(rs.eof) then
中的括号好象没用
 
这个问题已经解决,主要是语法问题,谢谢各位
 
顶部