![]() |
| 当前位置: > 首页 ->编程语言 ->ASP ->基于ASP的站内多值搜索 |
|
Web搜索界面如下:
采用枚举法的源程序如下: <%@ CODEPAGE = "936" %>
'连接数据库
<%
dim conn
dim DBOath
dim rs
dim sql
Set conn=Server.CreateObject("ADODB.Connection")
DBPath = Server.MapPath("addressbook.mdb")
conn.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & DBPath
Set rs=Server.CreateObject("ADODB.Recordset")
'从Web页获取姓名、电话、学校的值
dim Name
dim Tel
dim School
Name=request("Name")
Tel=request("Tel")
School=request("School")
'枚举法的搜索核心,因为有3个条件所以要写8组If判断语句
if trim(Name)="" and trim(Tel)="" and trim(School)="" then
sql="select * from address order by ID asc"
end if
if trim(Name)="" and trim(Tel)="" and trim(School)<>"" then
sql="select * from address where School like '%"&trim(School)&"%' order by ID asc"
end if
if trim(Name)="" and trim(Tel)<>"" and trim(School)="" then
sql="select * from address where Tel like '%"&trim(Tel)&"%' order by ID asc"
end if
if trim(Name)="" and trim(Tel)<>"" and trim(School)<>"" then
sql="select * from address where Tel like '%"&trim(Tel)&"%' and School like '%"&trim(School)&"%' order by ID asc"
end if
if trim(Name)<>"" and trim(Tel)="" and trim(School)="" then
sql="select * from address where Name like '%"&trim(Name)&"%' order by ID asc"
end if
if trim(Name)<>"" and trim(Tel)="" and trim(School)<>"" then
sql="select * from address where Name like '%"&trim(Name)&"%' and School like '%"&trim(School)&"%' order by ID asc"
end if
if trim(Name)<>"" and trim(Tel)<>"" and trim(School)="" then
sql="select * from address where Name like '%"&trim(Name)&"%' and Tel like '%"&trim(Tel)&"%' order by ID asc"
end if
if trim(Name)<>"" and trim(Tel)<>"" and trim(School)<>"" then
sql="select * from address where Name like '%"&trim(Name)&"%' and Tel like '%"&trim(Tel)&"%' and School like '%"&trim(School)&"%' order by ID asc" 如果您对本文有任何疑问或者建议,请到讨论区发表您的意见: >> 论坛入口 << 上一篇:用PreRender解决DataGrid分页最后一页行数不满的排版问题 下一篇:XLS与MDB文件格式互换全攻略 | ||||||||||||||||||||||||||||||||||||||||
| 【文章评论】 【收藏本文】 【推荐好友】 【打印本文】 【我要投稿】 【论坛讨论】 | |||||||||||||||||||||||||||||||||||||||||
| ·从本质上看网页(asp,jsp)的编写 | ·学以致用 驳“ASP低能论” ·用VB构建Internet的应用·Asp的安全管理(12)·Windows 2000 安全性技术概述--3·Windows 2000 安全性技术概述--2·Windows 2000 安全性技术概述--1·ActiveX技术综述(二) ·ActiveX技术综述(一) ·动态网页技术--CGI:ASP:JSP:PHP(4)|||||||||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||||||||
|
声明:刊登此文章是为了传递更多信息,文章内容仅供参考,转载请注明出处。 |
|||||||||||||||||||||||||||||||||||||||||