asp连接数据库代码实例(5)
发布时间:2021-06-06
发布时间:2021-06-06
asp 连接数据库代码实例
conn.close
response.write\"<script language=\'javascript\'>alert(\'所有信息已成功删除!\');location.href(\'?action=manage\');</script>\"
end if
if request(\"action\")=\"saveedit\" then
name=request.form(\"name\")
hits=request.form(\"hits\")
content=request.form(\"content\")
set rs=server.createobject(\"adodb.recordset\")
sql=\"select * from biao where id=\"&request(\"id\")&\"\"
rs.open sql,conn,3,2
rs(\"name\")=name
rs(\"content\")=content
rs(\"hits\")=hits
rs.update
conn.close
set rs=nothing
response.write \"<script language=javascript>alert(\'编辑成功!\');location.href(\'?id=\"&request(\"id\")&\"&action=edit\');</script>\"
end if
%>
---------------------------------
5。查询纪录
<form name="form1" method="post" action="search.asp">
<input name="keyword" type="text" id="keyword" size="25">
<select name="select" size="1">
<option value="name" selected>名称</option>
<option value="content">说明</option>
<option value="id">id</option>
</select>
<input type="submit" name="Submit" value="查询">
</form>
------search.asp---------------
<%
if request("keyword")<>"" and request("select")<>"" then
sql="select * from biao where "&request("select")&" like '%"&request("keyword")&"%'"
elseif request("keyword")<>"" and request("select")="all" then
sql="select * from biao where name like '%"&request("keyword")&"%' or id like '%"&request("keyword")&"%' or content like '%"&request("keyword")&"%'"