帮忙看一下下面的代码

dclovewj 2003-08-30 02:05:44
请教.用SQL怎么能实现
我自己做出来了但是不能运行.为什么
<% dim sfzh,xm,flag
sfzh=trim(request.form("sfzh")) //按身份证号或姓名或其它就没有写
xm=trim(request.form("xm"))
s1="select * 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%>
...全文
107 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
stefli 2003-08-30
  • 打赏
  • 举报
回复
s1="select * from ryjbqk where "
stefli 2003-08-30
  • 打赏
  • 举报
回复
在sl语句的后面where 后加一个空格.
liaijian 2003-08-30
  • 打赏
  • 举报
回复
直接写
s1="select * from ryjbqk where sfzh="&sfzh&"and xm like '%"&xm&"%'"
就可以了,不用if判断了

28,390

社区成员

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

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