| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1774 人关注过本帖
标题:求大神帮忙解决ASP+ACCESS多条件组合查询问题
只看楼主 加入收藏
葶依依
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2016-12-21
收藏
 问题点数:0 回复次数:0 
求大神帮忙解决ASP+ACCESS多条件组合查询问题
我有一个多条件组合查询,条件有6个。我有两个页面,一个是chaxun.asp用表单来输入查询条件, chaxunjieguo.asp接收表单的查询条件并显示查询结果。我输入查询条件后,查询出来的是相关表里的全部内容,没有实现按条件查询,求各位大神帮忙看看问题出在哪里,拜托拜托!!
下面是chaxunjieguo.asp部分代码:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="../../Connections/link.asp" -->
<%
dim qy
qy=0
 if request.form ("huiyimingcheng")  <>"" then   
  Sql="会议名称= '%"& request.form ("huiyimingcheng") &"%'"   '会议名称是Access表里的字段名
  qy=qy+1  
 end if   
 if request.form ("lingyu") <>"" then  
  if qy=0 then
  Sql= Sql & " 领域='%"& request.form ("lingyu") &" %'"  
  else
  Sql= Sql & " and 领域='%"& request.form ("lingyu") &" %'"
  end if
  qy=qy+1
end if   
 if request.form ("changjia") <>"" then
   if qy=0 then  
   Sql= Sql & " 厂家 like '%"& request.form ("changjia") &"%'"
   else
   Sql= Sql & " and 厂家 like '%"& request.form ("changjia") &"%'"
  end if
  qy=qy+1   
end if
 if request.form ("nianfen") <>"" then  
  if qy=0 then
  Sql= Sql & " 年 like '%"& request.form ("nianfen") &"%'"
  else
  Sql= Sql & " and 年 like '%"& request.form ("nianfen") &"%'"  
  end if
  qy=qy+1
end if
 if request.form ("yuefen") <>"" then
  if qy=0 then  
  Sql= Sql & " 月 like '%"& request.form ("yuefen") &"%'"
  else
  Sql= Sql & " and 月 like '%"& request.form ("yuefen") &"%'"  
  end if
  qy=qy+1
end if
 if request.form ("jiangzhe") <>"" then
  if qy=0 then  
  Sql= Sql & " 讲者 like '%"& request.form ("jiangzhe") &"%'"
  else
  Sql= Sql & " and 讲者 like '%"& request.form ("jiangzhe") &"%'"   
  end if
  qy=qy+1
end if
Sql= "Select * from T会议表 where 1=1"
 set rs=link.Execute(Sql)
%>
<%
Dim huiyichaxun
Dim huiyichaxun_numRows

Set huiyichaxun = Server.CreateObject("ADODB.Recordset")
huiyichaxun.ActiveConnection = MM_link_STRING
huiyichaxun.Source = "SELECT *  FROM [T会议表]"
huiyichaxun.CursorType = 0
huiyichaxun.CursorLocation = 2
huiyichaxun.LockType = 1
huiyichaxun.Open()
huiyichaxun_numRows = 0
%>
搜索更多相关主题的帖子: include file 
2016-12-21 10:41
快速回复:求大神帮忙解决ASP+ACCESS多条件组合查询问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014895 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved