当前位置: 首页 > 图文教程 > 网络编程 > ASP > 简单ASP论坛DIY

ASP
asp调用存储过程
利用批处理文件和 vbs 脚本实现网站视频自动录制
ASP、vbscript编码模板
FileSystem对象常用的文件操作函数有哪些?
asp显示日历效果
sql语句的一些集合
ASP语法注释
函数名称 函数功能
万能数据库连接程序
记录集内随机取记录的代码
分页代码
如何在数据库中用好Transaction?
用Command对象和RecordSet对象向数据库增加记录哪一个更好
为什么在存储过程中用OLEDB方式不能返回记录集
如何查询日期类型的数据?
ASP如何获取真实IP地址
两种小偷程序的比较
使用xmlHttp结合ASP实现网页的异步调用
用ASP开"多线程"
整理了一个editplus的剪辑文件(ASP方面的内容)

简单ASP论坛DIY


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-08-14   浏览: 92 ::
收藏到网摘: n/a

首先用Access新建一个数据库,设取名为luntan,数据表的名称为“information”,建立如下字段:“text”,“name”,“time”,并将“time”默认值设为Now()

以下为引用的内容:
<%

  Set com = Server.CreateObject("ADODB.Connection")

  com.open"DRIVER={Microsoft Access Driver("luntan.mdb");

pwd=information;DBQ="&Server.MapPath("luntan.mdb")

  sql="select*from information order by time Desc"

  Set rs=Server.CreateObject("ADODB.Recordest")

  rs.open sql,com,3,2

  if rs.EOF or rs.BOF then

  response.write"没有留言"

  else

    rs.MoveFirst

    while Not rs.EOF.

          response.write rs("name")&"发布于"&rs("time")&"<br>"

        response.write rs("text")&"<br><hr>"

       rs.MoveNext

  wend

AbsolutePosition=N,(N=1,2,3......)

  end if

  %>

接着是用户书写留言部分。设论坛页为“information.asp”,则

  <form method=post action="information.asp">

  姓名:<input type=text size=12 name="name"><br>

  留言:<textarea cols=30 row=4 name="text"></textarea><br>

  <input type=submit value="提交">

  </form>

最后一部分是将用户提交的表单数据记录到数据库中,则

以下为引用的内容:
 <%
  if request("text")<>empty and request ("name")<>empty then

  Set comb=Server.CreateObject("ADODB.Connection")

  comb.Open"DRIVER={Microsoft Access Driver(*.mdb)};pwd=information;

DBQ="&Server.MapPath("luntan.mdb")

  sql="select*from information"

  Set rsb=Server.CreateObject("ADODB.Recordset")

  rsb.open sql,comb,3,2

  rsb.AddNew

  rsb("text")=request("text")

  rsb("name")=request("name")

  rsb.update

  end if
%>