ASP提交关键词查询数据库示例
ASP
2025-01-07 13:18
89
0
index.htm
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>标题</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="Check.asp">
类别:
<label>
<input name="Leibie" type="text" id="Leibie" size="5" maxlength="5" />
</label>
<label>
<input type="submit" name="Submit" value="提交" />
</label>
</form>
</body>
</html>
Check.asp
<%
dim ConnString
set conn=server.CreateObject("adodb.connection")
ConnString="provider=microsoft.jet.oledb.4.0;data source=" & server.MapPath("数据库")
conn.open ConnString
set rs=server.CreateObject("adodb.recordset")
Leibie=request.form("Leibie")
if Leibie="" then
response.write "<script>alert('请输入查询的类别!');history.back();</script>"
response.end
else
sql="select * from where 数据表字段='"&Leibie&"'"
end if
rs.open sql,conn,1,3
%>
<%
if rs.bof and rs.eof then
response.write "<script>alert('暂无该类别相应内容!');history.back();</script>"
response.end
else
%>
<table><tr>
<td><% response.write "该类别记录总数为"&rs.recordcount %></td></tr>
<% do while not rs.eof %>
<tr><td>
<%
response.write rs("数据表字段")
rs.movenext
%></td></td>
<%loop%>
<tr><td><a href="index.htm">返回查询</a></td></tr></table>
%>