| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 493 人关注过本帖
标题:[求助]请大家帮助
只看楼主 加入收藏
闷得慌
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2005-11-17
收藏
 问题点数:0 回复次数:6 
[求助]请大家帮助

向大家请教个问题!
我做了一个组合查询的表单,可选择一个或多个进行填写,根据填写内容进行相应的查询。我编的这段代码有时候会出现错误,错误提示是说"HOTEL"附近有错误。请大家帮我看看问题出在哪里~
<%
Dim cnt,Str_Result
cnt = 0
hoid= Request("hoid")
city= Request("city")
star= Request("star")
price= Request("price")

if hoid <> "" then
Str_Result= "where hotel.hoid ='"&hoid&"'"
end if

if city=0 then
IF Str_Result="" then
Str_Result="where hotel.city=city.id"
else
Str_Result=Str_Result+"and hotel.city=city.id"
end if
end if

if city <>0 then
if Str_Result="" then
Str_Result="where hotel.city=city.id and city.id ='"&city&"'"
else
Str_Result=Str_Result+"and hotel.city=city.id and city.id ='"&city&"'"
end if
end if

if star=0 then
IF Str_Result="" then
Str_Result="where hotel.star=star.id"
else
Str_Result=Str_Result+"and hotel.star=star.id"
end if
end if

if star <> 0 then
if Str_Result="" then
Str_Result=" where hotel.star=star.id and star.id ='"&star&"'"
else
Str_Result=Str_Result+" and hotel.star=star.id and star.id ='"&star&"'"
end if
end if

if price=0 then
IF Str_Result="" then
Str_Result="where hotel.price=price.id"
else
Str_Result=Str_Result+"and hotel.price=price.id"
end if
end if

if price <> 0 then
if Str_Result="" then
Str_Result="where hotel.price=price.id and price.id ='"&price&"'"
else
Str_Result=Str_Result+" and hotel.price=price.id and price.id ='"&price&"'"
end if
end if

sql="select hotel.hoid,city.city,price.price,star.star from hotel,city,star,price " + Str_Result
set rs=Conn.Execute(sql)
response.write(sql)

Do While Not rs.Eof
cnt = cnt + 1
hoid = rs("hoid")
city = rs("city")
price= rs("price")
star= rs("star")


%>

搜索更多相关主题的帖子: star Request price where 
2005-11-17 20:53
盖茨他爹
Rank: 6Rank: 6
等 级:贵宾
威 望:28
帖 子:5255
专家分:0
注 册:2005-5-3
收藏
得分:0 
哪行啊?
2005-11-17 21:22
闷得慌
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2005-11-17
收藏
得分:0 
楼上的给指点一下?哪里有毛病?

2005-11-17 22:03
盖茨他爹
Rank: 6Rank: 6
等 级:贵宾
威 望:28
帖 子:5255
专家分:0
注 册:2005-5-3
收藏
得分:0 
提示的是第几行错误的,总不能让我一行一行的查
2005-11-17 22:07
yms123
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:209
帖 子:12488
专家分:19042
注 册:2004-7-17
收藏
得分:0 
可能楼主的SQL语句有问题。
2005-11-17 22:10
闷得慌
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2005-11-17
收藏
得分:0 

就是显示数据库有问题,但是我照逻辑把语句贴在查询分析器里是能查询出结果的,让我特别疑惑~~


2005-11-17 22:12
闷得慌
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2005-11-17
收藏
得分:0 
要不然我把文件给贴上大家瞧瞧!
真让人糟心啊~~
在这里谢谢大家了~~

2005-11-17 22:15
快速回复:[求助]请大家帮助
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.022488 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved