txt1=request.form("mytype")
txt2=request.form("fw_quyu")
txt5=request.form("fw_leixing")
txt4=request.form("fw_face")
txt6=request.form("textfield")
set rs=Server.CreateObject("ADODB.RecordSet")
'定义要查询的SQL语句
sql="select * from house where id<>''"
'判断是否选择了房屋性质
if txt1="" then
sql=sql
else
sql_name=" and "+"mytype='"& txt1 &"'"
sql=sql+sql_name
end if
'判断是否选择了区域类型
if txt2="" then
sql=sql
else
sql_info=" and "+" fw_quyu="& txt2 &""
sql=sql+sql_info
end if
'判断是否选择了房屋类型
if txt5 <>"" then
sql_qy=" and "+"fw_leixing='"& txt5 &"'"
sql=sql+sql_qy
else
sql=sql
end if
'判断是否选择了房屋朝向
if txt4 <>"" then
sql_cx=" and "+"fw_face='"& txt4 &"'"
sql=sql+sql_cx
else
sql=sql
end if
'判断是否输入了查询条件
if txt6<>"" then
sql_address=" and "+"textfield like '"& txt6 &"'"
sql=sql+sql_address
else
sql=sql
end if
sqlb=""&sql
response.write "sqlb="&sql
rs.open sqlb,conn,3,3
if rs.eof then
response.write"<script>alert('没有搜索到您要的任何结果,确定返回重新搜索!');history.back();</script>"
else
%>显示结果
<%end if%>
拼SQL时没有正确使用单引号,而且那个like后面的字符串也没有使用%%通配符,这样的结果就是把like变成了=
response.write "sqlb="&sql
| 论坛热门帖子: | [lch203] 写得蛮好的linux学习笔记(10-21) [黑马制造] 学习java的30个目标(10-19) [笑傲股林] 做测试半年了,有点迷茫,应该再学些什么提高自己的测试水平和测试能力呢?(10-19) [udp8589] 大家用google的来吱一声? 用百度的~~也来报道下?(10-18) [沂偌掳兆] 本人总结的一些认为C++比较经典的书籍,希望对大家有用(10-18) |
| TAG标签: | 为什么 无法 执行 错误 地方 帮忙 看看 代码 各位 sql |
注册
个人空间
