向大家请教个问题!
我做了一个组合查询的表单,可选择一个或多个进行填写,根据填写内容进行相应的查询。我编的这段代码有时候会出现错误,错误提示是说"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")
%>