index.html 代码:
-------------------------------------------------------------------------------------------
<!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>
<style type="text/css">
<!--
*{
margin:0;
padding:0;
}
ul{
list-style-type:none
clear:left;
margin:20px;
}
li{
float:left;
text-align:center
width:160px;
}
.label_Name{
width:100px;
height:25px;
font-size:14px
}
-->
</style>
</head>
<body>
<form action="search.asp" method="get" target="_self">
<ul>
<li class="label_name"><label for="keywords">站内搜索:</label></li>
<li><input type="text" id="keywords" name="keywords" /></li>
<li><input type="submit" value="查询" /></li>
</ul>
</form>
</body>
</html>
-------------------------------------------------------------------------------------------------------
search.asp 如下:
-------------------------------------------------------------------------------------------------------
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--#include file="Inc/conn.asp" -->
<html xmlns=" http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body>
<%
dim rs,sql,keywords
keywords=Server.CreateObject("keywords")
set rs=Server.CreateObject("Adodb.Recordset")
sql="select * from zhigong where name like '%"&keywords&"%' order by id desc"
rs.open sql,conn,1,1
Response.Write("姓名 工资<br />")
do while not rs.eof
Response.Write(rs("name"))
Response.Write(" ")
Response.Write(rs("gongzi"))
Response.Write("<br />")
rs.movenext
loop
%>
</body>
</html>
---------------------------------------------------------------------------------------------------------
conn.asp 如下:
---------------------------------------------------------------------------------------------------------
<%
dim conn
dim connstr
dim db
db="admin\database\Enterprise.mdb"
set conn = server.createobject("adodb.connection")
connstr="provider=Microsoft.Jet.OLEDB.4.0;Data source=" & server.MapPath(db)
conn.Open connstr
sub Closeconn()
conn.close
set conn=nothing
end sub
%>
--------------------------------------------------------------------------------------------------------
Server 对象, ASP 0177 (0x800401F3)
无效的类别字符串
/search.asp, 第 13 行
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; InfoPath.2)
GET /search.asp
2009年12月13日, 10:30:09