ASP里面的.未指定的错误,急啊~

来源:百度知道 编辑:UC知道 时间:2024/05/21 09:37:23
User=request("UserNames")
Types=request("TypeIds")
if User="" and Types="" then
response.write "<script>alert('请输入一个关键查询');history.back();</script>"
response.end
elseif User="" then
sql="select * from tb_ShouHou_info where Types like '%"&Types&"%'"
elseif Types="" then
sql="SELECT * FROM tb_ShouHou_info where Names like '%"&User&"%'"
else
sql="select * from tb_ShouHou_info where Names like '%"&User&"%' and Types like '%"&Types&"%'"
end if
rs.open sql,conn,1,3
if rs.bof and rs.eof then
response.write "<script>alert('你要查询的条件不存在');history.back();</script>"
response.end
else
................

上面是我写的一个双查询..可是..用户名那项一输入就会显示:

技术信息(用于支持人员)

错误类型:
(0x

48行是哪里?

并且在 rs.open sql,conn,1,3
的上面输出一下sql看看

response.write sql

----------------

给sql语句加括号试试。

sql="SELECT * FROM [tb_ShouHou_info] where [Names] like '%"&User&"%'"

elseif User="" then
sql="select * from tb_ShouHou_info where Types like '%"&Types&"%'"
elseif Types="" then
sql="SELECT * FROM tb_ShouHou_info where Names like '%"&User&"%'"
'以上这两你光判断某一个为空了,但没判断另外一个是否为空就把它作为条件,在它为空的情况下语句当然会出错了。
'改为下面这样
elseif User="" and Types<>"" then
sql="select * from tb_ShouHou_info where Types like '%"&Types&"%'"
elseif Types="" and User<>"" then
sql="SELECT * FROM tb_ShouHou_info where Names like '%"&User&"%'"

sql="select * from tb_ShouHou_info where Name