动态网站设计与开发 第五章
合集下载
相关主题
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
Like字句的使用
• 基本格式一:_匹配
– 姓名 like ‘_敏’
(姓名以敏结尾且字数为二的所有数据记录)
• 基本格式二:%匹配
– 姓名 like ‘%敏%’ (姓名中出现敏的所有数据记录)
网站模糊查询系统示例
<!--#include file="RsToTab.asp" --> <% Criteria=Request("Criteria") sql = "Select * From 黑名单" If Criteria <> "" Then
While Not rs.EOF Response.WRITE "<option>" & rs.Fields(1).Value & "</option>" rs.MoveNext
Wend Response.Write "</select>" %> <p><input type="submit" value="提交" name="B1"><input type="reset" value="
示例程序5-11.asp
<!--#include file=rstotab.asp --> <% DB = Request("DB") If DB = Empty Then DB = "Sample.mdb" SQL = Request("SQL") If SQL = Empty Then SQL = "Select * From 成绩单" Set conn = Server.CreateObject("ADODB.Connection") conn.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & Server.MapPath(db) Set rs = conn.Execute( sql ) %> <HTML> <BODY bgcolor=beige> <FORM Action="5-11.asp" Method=POST> 数据库:<INPUT Type=Text Name=DB Value="<%=DB%>"><BR> 指令:<INPUT Type=Text Name=SQL Size = 60 Value="<%=SQL%>"><P> <INPUT Type=Submit Value=" 执行"> </FORM> <% If Not (rs Is Nothing) Then %> <% rstotable rs%> <%Else%> <HR><FONT Color=Red>Select 指令错误!</FONT> <%End If%> </BODY> </HTML>
<p>请输入人名的关键字:<input NAME="Criteria" Value="<%=Criteria%>" SIZE="40"><input TYPE="Submit" VALUE="查询"> </p> </form> <hr WIDTH="50%"> <% Set conn = Server.CreateObject("ADODB.Connection") conn.open "driver={Microsoft Access Driver (*.mdb)};dbq=" & Server.MapPath("szg.mdb") response.write sql Set rs = conn.Execute(sql) RsToTable rs %> </body> </html>
Select基本句型二Leabharlann Baidu
• Select 字段串列 from 数据表 where 筛选条件 • 如:
– Select * from 成绩单 where asp>60 – Select * from 成绩单 where asp=300 or gre=300 or toefl=300
Select基本句型三
网站精确查询系统程序一main.asp
<% Set conn = Server.CreateObject("ADODB.Connection") conn.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" &
Server.MapPath("sample.mdb") Set rs = conn.Execute("成绩单") %> <form method="POST" action="handle.asp"> <% Response.Write "<select size=1 name=name>"
sql = sql & " Where 姓名 like "&"'%" & Criteria&"%'" End If %> <html> <head> </head> <body bgcolor="beige"> <h2 ALIGN="CENTER">实现网站的模糊查询:</h2> <form action="mh.asp" method="GET">
全部重写" name="B2"></p> </form>
网站精确查询系统程序二handle.asp
<!--#include file=rstotab.asp --> <% DB = "Sample.mdb" name = Request("name") SQL = "Select * From 成绩单 where 姓名='"&name&"'" response.write sql Set conn = Server.CreateObject("ADODB.Connection") conn.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & Server.MapPath(db) Set rs = conn.Execute( sql ) %> <HTML> <BODY bgcolor=beige> <% If Not (rs Is Nothing) Then %> <% rstotable rs%> <%Else%> <HR><FONT Color=Red>Select 指令错误!</FONT> <%End If%> </BODY> </HTML>
• Select 字段串列 from 数据表 order by 字段串列 • 如:
– Select * from 成绩单 order by gre – Select * from 成绩单 order by gre,toefl – Select * from 成绩单 order by tse desc – Select top 5 * from 成绩单