ASP问题 查询不到记录提示重新输入

来源:百度知道 编辑:UC知道 时间:2024/06/07 07:06:44
如果没有符合条件的记录则显示 “请重新选择查询条件”

<% dim rs,query,str,curpage
Set rs = Server.CreateObject("ADODB.Recordset")

tj=Trim(request("tj"))
cxtj=Trim(request("cxtj"))

if tj<>"" then

str="SELECT * FROM info WHERE "&cxtj&" like '%"&tj&"%' ORDER BY username"

rs.Open str,conn,1,1

%>
cxtj 为下拉列表 tj 为 文本框

<% dim rs,query,str,curpage
Set rs = Server.CreateObject("ADODB.Recordset")

tj=Trim(request("tj"))
cxtj=Trim(request("cxtj"))

if tj<>"" then

str="SELECT * FROM info WHERE "&cxtj&" like '%"&tj&"%' ORDER BY username"

rs.Open str,conn,1,1
if rs.bof and rs.eof then
response.write "请重新选择查询条件"
response.end()
response.write "<script>history.back();</script>"
end if
%>

<% dim rs,query,str,curpage
Set rs = Server.CreateObject("ADODB.Recordset")

tj=Trim(request("tj"))
cxtj=Trim(request("cxtj"))

if tj="" then
response.write "<script LANGUAGE='javascript'>alert('请重新选择查询条件!');history.go(-1);</script>"
else
str="SELECT * FROM info WHERE "&cxtj&&quo