This presentation is the property of its rightful owner.
Sponsored Links
1 / 28

第十一讲 ASP 应用之三:查询记录 PowerPoint PPT Presentation


  • 53 Views
  • Uploaded on
  • Presentation posted in: General

第十一讲 ASP 应用之三:查询记录. 通过留言簿数据库实例讲解如何查询指定记录。. 查询语句的具体应用. 格式 :( 1 )单条件查询: SELECT * FROM 表 WHERE 条件 ( 2 )多个条件的查询: SELECT * FROM 表 WHERE 条件 1 OR 条件 2 SELECT * FROM 表 WHERE 条件 1 AND 条件 2. 在我们的例子中,我们是要查询商品名称或描述中包含用户输入的文字的商品。这里,就有两个查询条件,条件 1 是指商品名称中包含有用户输入的文字,条件 2 是商品描述中包含用户输入的文字。.

Download Presentation

第十一讲 ASP 应用之三:查询记录

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Asp

ASP


Asp

  • 1SELECT * FROM WHERE

  • 2

  • SELECT * FROM WHERE 1 OR 2

  • SELECT * FROM WHERE 1 AND 2


Asp

  • 12


Asp

SQLLIKE.....%%


Asp

1%%

2%

3%%%


Asp

%

1

Name like '% Request.Form("txtName")%'% %


Asp

Request.Form("txtName")Name like '%%'


Asp

2

Description like '% Request.Form("txtName")%'


Asp

SQL

SELECT * FROM catalog WHERE (Name like '% Request.Form("txtName")%') OR (Description like '% Request.Form("txtName")%')


Asp

Trim (Name like '% Trim Request.Form("txtName")%') (Description like '% TrimRequest.Form("txtName")%')


Asp

SELECT * FROM catalog WHERE (Name like '% Trim(Request.Form("txtName"))') OR (Description like '% Trim(Request.Form("txtName"))')


Asp

SQLasp

asp

sqlRecordset1.Source+SQLselect * from catalog where (name like '%%Trim()Trim()+


Asp

asp

"SELECT * FROM catalog WHERE (Name like '%"+ Trim(Request.form("txtName")) + "%') OR (Description LIKE '%" + Trim(Request.form("txtName")) + "%')"


Asp

  • select


Asp

  • 1 searchcatalog.asp


Asp

radWhichRule


Asp

2 searchresult.asptxtNameradWhichRuleselCategoryrstSearchResultSQL


Asp

  • SQLORwhere (1) OR 21mmWhichRuleStr=bykeywordnamedescriptionAND2 category='mmCategoryStr'


Asp

  • if Replace(Recordset1__mmWhichRuleStr, "'", "''") = "bykeyword" then

  • Recordset1.Source = "SELECT * FROM catalog WHERE (Name like '%" + Trim(Replace(Recordset1__mmNameStr, "'", "''")) +"%') OR (Description like '%"+ Trim(Replace(Recordset1__mmNameStr, "'", "''"))+"%')"

  • else

  • Recordset1.Source = "SELECT * FROM catalog WHERE category= '" + Replace(Recordset1__mmCategoryStr, "'", "''") + "'"

  • end if


Asp

  • 3


Asp

  • <%set conn=server.createobject("adodb.connection")conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.mappath("example3.mdb")exec="select * from guestbook"set rs=server.createobject("adodb.recordset")rs.open exec,conn,1,1 %>


Asp

a=""b=111 exec="select * from guestbook where name='"+a+"'and tel="+bwhereandorname111

where instr(name,a)namea


Asp

a,b,a,b

search.htm

<form name="form1" method="post" action=search.asp"><br>name =<input type="text" name="name">and tel= <input type="text" name="tel"><br><input type="submit" name="Submit" value=""><input type="reset" name="Submit2" value=""></form>


Asp

<%name=request.form("name")tel=request.form("tel")set conn=server.createobject("adodb.connection")conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.mappath(guestbook.mdb")exec="select * from guestbook where name='"+name+"' and tel="+telset rs=server.createobject("adodb.recordset")rs.open exec,conn,1,1%><html><head><title></title><meta http-equiv="Content-Type" content="text/html; charset=gb2312"></head> <body bgcolor="#FFFFFF" text="#000000"> <table width="100%" border="0" cellspacing="0" cellpadding="0"><%do while not rs.eof%><tr><td><%=rs("name")%></td><td><%=rs("tel")%></td><td><%=rs("message")%></td><td><%=rs("time")%></td></tr><%rs.movenextloop%></table></body></html>


Asp

exec=delete * from guestbook where id=&request.form(id)ididexec=delete * from guestbook where =&request.form(id)delete.htm.ASPIDASPID<form name="form1" method="post" action=delete.asp">delete: <input type="text" name="id"><input type="submit" name="Submit" value=""></form>


Asp

<%set conn=server.createobject("adodb.connection")conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.mappath("example3.mdb")exec="select * from guestbook"set rs=server.createobject("adodb.recordset")rs.open exec,conn,1,1 %>

  • <html><head><title></title><meta http-equiv="Content-Type" content="text/html; charset=gb2312"></head>

  • <body bgcolor="#FFFFFF" text="#000000">

  • <table width="100%" border="0" cellspacing="0" cellpadding="0"><%do while not rs.eof%><tr><td><%=rs("")%></td><td><%=rs("name")%></td><td><%=rs("tel")%></td><td><%=rs("message")%></td><td><%=rs("time")%></td></tr><%rs.movenextloop%></table></body></html>


Asp

  • :where instr( )

  • .


  • Login