多条件搜索

实现代码:
sqltext=""
if Hao_Province="省份" then '如果没有选择省份
sqltext=sqltext
else '如果选择了省份
sql_Province="Province='"+Hao_Province+"'"
sqltext=sqltext+sql_Province
end if
if Hao_City="城市" then ' 如果没有选择城市
sqltext=sqltext
else '如果选择了城市
if Hao_Province<>"省份" then '在前面选择了省份
sql_City=" and "+"City='"+Hao_City+"'"
else
sql_City="City='"+Hao_City+"'"
end if
sqltext=sqltext+sql_City
end if
If Hao_District="区县" Then '如果没有选择区县
sqltext=slqtext
else '如果选择了区县
if Hao_Province<>"省份" or Hao_City<>"城市" then '在前面选择了省份或城市
sql_District=" and "+"district='"+Hao_District+"'"
else
sql_District="district='"+Hao_District+"'"
end if
sqltext=sqltext+sql_District
end if
If Hao_lb="全部" Then '类别
sqltext=sqltext
else
if Hao_Province<>"省份" or Hao_City<>"城市" or Hao_District<>"区县" then
sql_lb=" and "+"xxlx='"+Hao_lb+"'"
else
sql_lb="xxlx='"+Hao_lb+"'"
end if
sqltext=sqltext+sql_lb
end if
If Hao_huxing="请选择" Then '户型
sqltext=sqltext
else
if Hao_Province<>"省份" or Hao_City<>"城市" or Hao_District<>"区县" or Hao_lb<>"全部信息" then
sql_huxing=" and "+"huxing='"+Hao_huxing+"'"
else
sql_huxing="huxing='"+Hao_huxing+"'"
end if
sqltext=sqltext+sql_huxing
end if
If Hao_mianji1="" or Hao_mianji2 ="" Then '面积
sqltext=sqltext
else
if Hao_Province<>"省份" or Hao_City<>"城市" or Hao_District<>"区县" or Hao_lb<>"全部信息" or Hao_huxing<>"" then
sql_mianji=" and "+"mianji between "+Hao_mianji1+" and "+Hao_mianji2
else
sql_mianji="mianji between "+Hao_mianji1+" and "+Hao_mianji2
end if
sqltext=sqltext+sql_mianji
end if
if Hao_Price1="" or Hao_Price2="" then '价格
sqltext=sqltext
else
if Hao_Province<>"省份" or Hao_City<>"城市" or Hao_District<>"区县" or Hao_lb<>"全部信息" or Hao_huxing<>"" or ((Hao_mianji1<>"") and(Hao_mianji2<>"")) then
sql_Price=" and "+"jiage between "+ Hao_Price1 + " and "+Hao_Price2
else
sql_Price="jiage between " + Hao_Price1 +" and "+Hao_Price2
end if
sqltext=sqltext+sql_Price
end if
if Hao_Price="" then '价格单位
sqltext=sqltext
else
if Hao_Province<>"省份" or Hao_City<>"城市" or Hao_District<>"区县" or Hao_lb<>"全部信息" or Hao_huxing<>"" or ((Hao_mianji1<>"") and(Hao_mianji2<>"")) or ((Hao_Price1<>"") and(Hao_Price2<>""))then
sql_Price2=" and "+"jgdw='"+Hao_Price+"'"
else
sql_Price2="jgdw='"+Hao_Price+"'"
end if
sqltext=sqltext+sql_Price2
end if
if sqltext="" then
sqltext="select * from zj "+sqltext+" order by id desc"
else
sqltext="select * from zj where "+sqltext+" order by id desc"
end if
set rs=Server.Createobject("ADODB.Recordset")
rs.open sqltext,conn,1,1