实现多个条件综合查询 或是分别查询怎么实现,请教

dclovewj 2003-08-30 12:05:06

请教我就是按如下代码意思写的根据这个意思编写出可按我个条件综合查询
<!--#include file="conn.asp"-->
<html>
<head>
<title></title>
</head>
<body>
<% dim sfzh,xm,xb,flag //可按身份证号或姓名或性别
sfzh=trim(request.form("sfzh"))
xm=trim(request.form("xm"))
s1="select xm ,sfzh ,xb ,dwmc ,zgbm from ryjbqk where"
if sfzh<>"" then
s1=s1&"sfzh='"&sfzh&"'"
flag=1
end if
if xm<>"" and flag=1 then
s1=s1&"and xm like '%"&xm&"%'"
flag=1
else if xm<>"" then
s1=s1&"xm like '%"&xm&"%'"
flag=1
end if


rs.open s1,conn,1,1
if not rs.eof then%>

<TABLE>
<%do while not rs.eof %>
<TR align=middle>
<% for i=0 to rs.fields.count-1%>
<td ><%=rs(i).value%></td>
<% next%>
</TR>
<% rowcount=rowcount-1
rs.movenext
loop
rs.close
set rs=nothing%>
</TABLE>
<% end if%>
</body>
</html>
...全文
81 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
李睿_Lee 2003-08-30
  • 打赏
  • 举报
回复
楼上的代码有冗余,后一个判断改为:

if xm<>"" and flag=1 then
s1=s1&"and xm like '%"&xm&"%'"
flag=1
else
s1=s1&"xm like '%"&xm&"%'"
flag=1
end if
wolf004 2003-08-30
  • 打赏
  • 举报
回复
意思就是查询啊!
精典的就这段
s1="select xm ,sfzh ,xb ,dwmc ,zgbm from ryjbqk where"
if sfzh<>"" then
s1=s1&"sfzh='"&sfzh&"'"
flag=1
end if
if xm<>"" and flag=1 then
s1=s1&"and xm like '%"&xm&"%'"
flag=1
else if xm<>"" then
s1=s1&"xm like '%"&xm&"%'"
flag=1
end if
stefli 2003-08-30
  • 打赏
  • 举报
回复
s1="select xm ,sfzh ,xb ,dwmc ,zgbm from ryjbqk where"
where后面加一个空格
stefli 2003-08-30
  • 打赏
  • 举报
回复
1,1
就可以了.
dclovewj 2003-08-30
  • 打赏
  • 举报
回复
RS.OPEN S1,CONN,之后用数字几呢.

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧