各位帮我看看我的搜索功能哪里出问题了?
说明:共4个搜索条件,分别为class1,class2,城市和关键字其中class1 和class2 两者不同时为空,城市(province,city)和关键字(keywords)可以为空
代码如下,请帮我看看那里出问题了,错误提示为ADODB.Recordset (0x800A0BB9)参数类型不正确,或不在可以接受的范围之内,或与其他参数冲突。(连接数据库正确)或者有没有其他的方法可行。我觉得这样太复杂了,谢谢了!
<%
set rs2=server.CreateObject("adodb.recordset")
if request("class1")="" and request("class2")<>"" then
if request("province")="" and request("keywords")="" then
sql="select * from ad where class2='"&request("class2")&"'"
else
if request("province")<>"" and request("keywords")<>"" then
sql="select * from ad where class2='"&request("class2")&"' and province='"&request("province")&"' and city='"&request("city")&"' and keywords like '%"&request("keywords")&"%'"
else
if request("province")<>"" and request("keywords")="" then
sql="select * from ad where class2='"&request("class2")&"' and province='"&request("province")&"' and city='"&request("city")&"'"
else
if request("province")="" and request("keywords")<>"" then
sql="select * from ad where class2='"&request("class2")&"' and keywords like '%"&request("keywords")&"%'"
end if
end if
end if
end if
else
if request("class1")<>"" and request("class2")="" then
if request("province")="" and request("keywords")="" then
sql="select * from ad where class1='"&request("class1")&"'"
else
if request("province")<>"" and request("keywords")<>"" then
sql="select * from ad where class1='"&request("class1")&"' and province='"&request("province")&"' and city='"&request("city")&"' and keywords like '%"&request("keywords")&"%'"
else
if request("province")<>"" and request("keywords")="" then
sql="select * from ad where class1='"&request("class1")&"' and province='"&request("province")&"' and city='"&request("city")&"'"
else
if request("province")="" and request("keywords")<>"" then
sql="select * from ad where class1='"&request("class1")&"' and keywords like '%"&request("keywords")&"%'"
end if
end if
end if
end if
else
if request("class1")<>"" and request("class2")<>"" then
if request("province")="" and request("keywords")="" then
sql="select * from ad where class2='"&request("class2")&"' and class1='"&request("class1")&"'"
else
if request("province")<>"" and request("keywords")<>"" then
sql="select * from ad where class2='"&request("class2")&"' and class1='"&request("class1")&"' and province='"&request("province")&"' and city='"&request("city")&"' and keywords like '%"&request("keywords")&"%'"
else
if request("province")<>"" and request("keywords")="" then
sql="select * from ad where class2='"&request("class2")&"' and class1='"&request("class1")&"' and province='"&request("province")&"' and city='"&request("city")&"'"
else
if request("province")="" and request("keywords")<>"" then
sql="select * from ad where class2='"&request("class2")&"' and class1='"&request("class1")&"' and keywords like '%"&request("keywords")&"%'"
end if
end if
end if
end if
end if
end if
end if
rs2.open str,conn,1,1
%>