简单的asp记录查询

2013年08月08日 安全技术 热度775 查看评论

 

 一、查询页:scan.asp

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

 <form name="form1" method="post" action="scan1.asp">
搜索:<p><br>
姓名:
<input type="text" name="name">
或 电话: 
<input type="text" name="tel">
</p>
<p>
<br>
<input type="submit" name="Submit" value="搜索">
<input type="reset" name="Submit2" value="重置">
</p>
</form>

 

 

二、结果显示页面:scan2.asp

<%
name=request.form("name")
tel=request.form("tel")
if tel="" then
tel="1"
end if
set conn=server.createobject("adodb.connection")
conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.mappath("data.mdb")
exec="select * from user where name like '%"&name&"%' and tel like '%"&tel&"%'"
set rs=server.createobject("adodb.recordset")
rs.open exec,conn,1,1
%>


<table width="759" height="10" border="0">
  <tr>
    <th width="110" scope="col"><div align="center">姓名</div></th>
    <th width="110" scope="col"><div align="center">密码</div></th>
    <th width="110" scope="col"><div align="center">性别</div></th> 
    <th width="110" scope="col"><div align="center">城市</div></th>
 <th width="110" scope="col"><div align="center">手机</div></th>
    <th width="112" scope="col"><div align="center">QQ</div></th>
    <th width="67" scope="col"><div align="center">备注</div></th>
  </tr>
</table>

<table width="759" border="0" align="left" cellpadding="0" cellspacing="0">
<%do while not rs.eof%><tr>
<td width="116"><div align="center"><%=rs("name")%></div></td>
<td width="113"><div align="center"><%=rs("password")%></div></td>
<td width="116"><div align="center"><%=rs("sex")%></div></td>
<td width="113"><div align="center"><%=rs("city")%></div></td>
<td width="116"><div align="center"><%=rs("tel")%></div></td>
<td width="112"><div align="center"><%=rs("qq")%></div></td>
<td width="73"><div align="center"><%=rs("other")%></div></td>


<%
rs.movenext
loop
%>
</table>

 

 

 

 

 

 

 

 

 

 

 

« 上一篇 下一篇 » 光原创文章,转载请注明出处! 标签:asp查询

相关日志:

说两句吧:

必填

选填

选填

«    2023年8月    »
123456
78910111213
14151617181920
21222324252627
28293031
搜索
文章归档
最近发表
站点信息
  • 文章总数:782
  • 页面总数:2
  • 分类总数:14
  • 标签总数:522
  • 评论总数:359
  • 浏览总数:624719