|
常常有人问,总结下:
- '查询数据库
- <%
- set rs=server.createobject("adodb.recordset")
- sql="select * from main order by id desc"
- rs.open sql,conn,1,1
- %>
- <%do while not rs.eof%>
- '显示数据
- <%
- rs.movenext
- loop
- rs.close
- set rs=nothing
- conn.close
- set conn=nothing
- %>
- '添加记录
- <%
- set rs=server.createobject("adodb.recordset")
- sql="select user,qq,email,content,data from main"
- rs.open sql,conn,1,3
- rs.addnew
- user=request.form("user")
- qq=request.form("qq")
- email=request.form("email")
- content=request.form("content")
- rs("user")=user
- rs("qq")=qq
- rs("email")=email
- rs("content")=content
- rs.update
- rs.close
- set rs=nothing
- conn.close
- set rs=nothing
- %>
- '删除记录
- <%
- set rs=server.createobject("adodb.recordset")
- id=Request.QueryString("id")
- sql="select * from main where id="&id
- rs.open sql,conn,2,3
- rs.delete
- rs.update
- %>
复制代码 |
|