2005-10-04

ASP的多条件动态查询

来源: 本站收集整理 作者:佚名 评论 0 条
 
以下是对form表单的处理:
〈!--假如在form中点击“搜索”按钮--〉
〈%
if Request(“btn_seek”)〈〉 Empty then
〈!--获得查询者输入信息--〉
seek_name=Trim(Request(“txt_name”))
seek_xueli=Trim(Request(“sel_xueli”))
seek_zhicheng=Trim(Request(“sel_zhicheng”))
seek_zhuangkuang=Trim(Request
(“sel_zhuangkuang”))
〈!--假如查询者什么都没有输入--〉
if((seek_name=“”) and (seek_xueli=“选择”)
and (seek_zhicheng=“选择”) and
(seek_zhuangkuang=“选择”)) then %〉
〈center〉〈h2〉〈font color=“#FF0033”〉
〈%Response.Write “您没有输入查询条件!” %〉〈BR〉〈BR〉
〈%Response.Write “请输入条件后查询!!!” %〉〈BR〉〈BR〉
〈/font〉〈/h2〉
〈input type=“button” name=“btn_goback”value=“返回” onclick=“javascript:history.go(-1)”〉
〈/center〉
〈%Response.End%〉
〈% end if
〈!--定义要查询的SQL语句--〉
sql_text=“select * from operator where ”
〈!--查看是否输入了人名--〉
if seek_name=“” then
〈!--假如没有输入人名--〉
sql_text=sql_text
else 〈!--假如输入了人名--〉
sql_name=“name =‘“&seek_name&”’”
sql_text=sql_text+sql_name
end if
〈!--查看是否选择了学历--〉
if seek_xueli=“选择” then
〈!--假如没有选择学历--〉
sql_text=sql_text
else 〈!--假如选择了学历--〉
if (seek_name〈〉“”) then
〈!--在前面输入了要查询的人名--〉
sql_xueli=“ and “+”educationallever =‘“&seek_xueli&”’”
else
sql_xueli=“educationallever =‘“&
seek_xueli&”’”
end if
sql_text=sql_text+sql_xueli
end if
〈!--查看是否选择了职称--〉
if seek_zhicheng=“选择" then
〈!--假如没有选择职称--〉
sql_text=sql_text
else 〈!--假如选择了职称--〉
if ((seek_name〈〉“”) or (seek_xueli〈〉“选择”)) then
〈!--在前面输入了人名或选择了学历--〉
sql_zhicheng=“ and “+”grade =‘“&seek_zhicheng&”’”
else 〈!--仅选择了职称--〉
sql_zhicheng=“grade =‘“&
seek_zhicheng&”’”
end if
sql_text=sql_text+sql_zhicheng
end if
〈!--查看是否选择了现在状况--〉
if seek_zhuangkuang=“选择” then
〈!--假如没有选择现在状况--〉
sql_text=sql_text
else 〈!--选择了现在状况--〉
if ((seek_name〈〉“”) or (seek_xueli〈〉“选择”) or (seek_zhicheng〈〉“选择”)) then
〈!--在前面输入了人名或选择了学历或选择了职称--〉
sql_zhuangkuang=“ and “+”state =‘“&seek_zhuangkuang&”’”
else 〈!--仅选择了现在状况--〉
sql_zhuangkuang=“state =‘“&
seek_zhuangkuang&”’”
end if
sql_text=sql_text+sql_zhuangkuang
end if
〈!--按记录时间倒序显示--〉
sql_text=sql_text+“ order by time desc”
else 〈!--假如在form中点击“浏览”按钮--〉
sql_text=“select * from operator order by time desc”
end if
Myself = Request.ServerVariables(“PATH_INFO”)
〈!--连接SQL Serve数据库,机器名为“comm_server”,数据库名称为“comm_server ”,以“sa”的身份访问,密码为空--〉
共3页: 上一页 [1] 2 [3] 下一页
(本文仅表明作者个人观点,不代表本站及其管理员立场.) 推荐 收藏 投稿 打印 返回 关闭
上一篇:高手感悟:走向J2EE,漫长的道路  
下一篇:C#中的函数重载
    评论加载中…
 推荐文章
     

网站首页  -  网站地图 -   站长论坛  -  网站投稿  -    -  网站管理
Copyright © 2008 芜湖站长站 All Rights Reserved 皖ICP备07500611号