-
达令说
if request("neirong")<>"" and request("riqi1")=""thensql="select * from renyuan where id="&request("id")&" and "&request("tiaojian")&"='"&request("neirong")&"'"elseif request("neirong")="" and request("riqi1")<>"" and request("riqi2")<>"" thensql="select * from renyuan where id="&request("id")&" and shengri between #"&request("riqi1")&"# and #"&request("riqi2")&"#"elseif request("neirong")<>"" and request("riqi1")<>"" and request("riqi2")<>"" thensql="select * from renyuan where id="&request("id")&" and "&request("tiaojian")&"='"&request("neirong")&"'and shengri between #"&request("riqi1")&"# and #"&request("riqi2")&"#"end if
-
素胚勾勒不出你
这就是SQL拼接的问题了!如:sql="1=1"if request("条件1")<>"" then sql=sql&" and 查询字段1='"&request("条件1")&"'"if request("条件2")<>"" then sql=sql&" and 查询字段2='"&request("条件2")&"'"if request("条件3")<>"" then sql=sql&" and 查询字段3='"&request("条件3")&"'"if request("条件4")<>"" then sql=sql&" and 查询字段4='"&request("条件4")&"'"if request("条件5")<>"" then sql=sql&" and 查询字段5='"&request("条件5")&"'"if request("条件6")<>"" then sql=sql&" and 查询字段6 like '%"&request("条件6")&"%'" '模糊查询if request("条件N")<>"" then sql=sql&" and 查询字段N='"&request("条件N")&"'"这样的就把SQL的条件语句给拼接了,然后再看以下:set rs=server.createobject("adodb.recordset")sql="select * from 表名 where "&sql&""rs.open sql,conn,1,1
-
一只斗牛犬
思路:1、表单页面,设置多个查询的文本框<form name="search" method="post" action="searchresult.asp">学生名字:<input type="text" name="studentname" />联系方式:<input type="text" name="Tel" /><input type="submit" name="submit" value="提交查询" class="formsubmit" /></form>2、表单处理页面,根据查询文本框的内容,组合成SQL语句,到数据库中查询<%studentname = trim(request.Form("studentname"))Tel = trim(request.Form("Tel"))sql = "select * from [tablename] where ()"If studentname <> "" Thensql = sql & " and replace(studentname,' ','') like '%" & studentname & "%'"End Ifif Tel <> "" thensql =sql &" and studentTel like '%"&Tel&"%'"End Ifrs.open session("sql"),ConnDb,1,1If rs.eof And rs.bof Then'提示信息Else'输出数据End If%>不知道你目前做到什么程序了。