📄 十天学会asp之第六天.htm
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0046)http://www.xiaoz.com/code/10today/10today6.htm -->
<HTML><HEAD><TITLE>十天学会ASP之第六天</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312"><LINK
href="十天学会ASP之第六天.files/main.css" type=text/css rel=stylesheet>
<STYLE type=text/css>.style1 {
FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif
}
.style2 {
COLOR: #99cc00
}
</STYLE>
<META content="MSHTML 6.00.2600.0" name=GENERATOR></HEAD>
<BODY bgColor=#ffffff><IFRAME src="十天学会ASP之第六天.files/head.htm" frameBorder=0
width=726 scrolling=no height=172></IFRAME>
<TABLE cellSpacing=0 cellPadding=0 width=800 border=0>
<TBODY>
<TR>
<TD>
<TABLE class=t6right cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD vAlign=top><IMG height=1 src="十天学会ASP之第六天.files/spacer.gif"
width=800></TD></TR>
<TR>
<TD class=black14 height=50>
<UL>
<LI><STRONG>十天学会ASP之第六天 </STRONG> [<A
class="black14 style2"
href="javascript:window.close()">关闭窗口</A>] 发布时间:[2004年6月14日]
</LI></UL></TD></TR>
<TR>
<TD
class=black14>学习目的:学会数据库的基本操作2(查询记录)<BR> 在第四天中我们有这样一个程序:<BR><%<BR>set conn=server.createobject("adodb.connection")<BR>conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.mappath("example3.mdb")<BR>exec="select * from guestbook"<BR>set rs=server.createobject("adodb.recordset")<BR>rs.open exec,conn,1,1 <BR>%><BR>我们查询的是所有的记录,但是我们要修改、删除记录的时候不可能是所有记录,所有我们要学习检索合适的记录。先看一条语句:<BR>a="张三"<BR>b=111 <BR>exec="select * from guestbook where name='"+a+"'and tel='"+b+"'<BR>where后面加上的是条件,与是and,或是or,我想=,<=,>=,<,>的含义大家都知道吧。这句话的意思就是搜索name是张三的,并且电话是111的记录。还有一点就是如果要搜索一个字段里面是不是包含一个字符串就可以这么写:where instr(name,a)也就是搜索name里面有a(张三)这个字符串的人。<BR>我这里的a,b,是常量,大家可以让a,b是表单提交过来的变量,这样就可以做一个搜索了。<BR>下面大家看看这个代码,理解一下:<BR><form name="form1" method="post" action="example6.asp"><BR>搜索:<br><BR>name =<BR><input type="text" name="name"><BR>and tel= <BR><input type="text" name="tel"><BR><br><BR><input type="submit" name="Submit" value="提交"><BR><input type="reset" name="Submit2" value="重置"><BR></form><BR><BR><BR>example6.asp:<BR><%<BR>name=request.form("name")<BR>tel=request.form("tel")<BR>set conn=server.createobject("adodb.connection")<BR>conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.mappath("example3.mdb")<BR>exec="select * from guestbook where name='"+name+"' and tel='"+tel+"'"<BR>set rs=server.createobject("adodb.recordset")<BR>rs.open exec,conn,1,1<BR>%><BR><html><BR><head><BR><title>无标题文档</title><BR><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><BR></head> <BR><body bgcolor="#FFFFFF" text="#000000"> <BR><table width="100%" border="0" cellspacing="0" cellpadding="0"><BR><%<BR>do while not rs.eof<BR>%><tr><BR><td><%=rs("name")%></td><BR><td><%=rs("tel")%></td><BR><td><%=rs("message")%></td><BR><td><%=rs("time")%></td><BR></tr><BR><%<BR>rs.movenext<BR>loop<BR>%><BR></table><BR></body><BR></html> <BR><BR>今天实际上就讲了一个where,大家回去做做试验,把instr()做进去,明天见!<A
href="http://www.xiaoz.com/code/10today/example6.rar">点击下载</A></TD></TR>
<TR>
<TD height=30> </TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE><IFRAME
src="十天学会ASP之第六天.files/foot.htm" frameBorder=0 width=780 scrolling=no
height=90></IFRAME></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -