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

ASP
通过ASP与ACCESS数据库建立连接(附源码)(1)
通过ASP与ACCESS数据库建立连接(附源码)(2)
通过ASP与ACCESS数据库建立连接(附源码)(3)
关于页面局部刷新例程
仿照CHINAASP论坛中TOP10写的部分显示代码
用ASP做一个记事本编缉器(附源码)
让您的主页支持各种浏览设备(ASP+篇)(下)
用ASP开发一个在线考试程序(五)
用ASP开发一个在线考试程序(六)
用ASP开发一个在线考试程序(七)
用ASP开发一个在线考试程序(八)
用ASP开发一个在线考试程序(九)
用SQL Server为Web浏览器提供图像1
用SQL Server为Web浏览器提供图像2
用SQL Server为Web浏览器提供图像3(end)
制作一个个人搜索引擎(源码)
制作一个简单的服务器端控制
用Access制作一个功能完善的论坛(源程序)
广告播放和跟踪系统的制作
动态广告管理程序制作例子

简单ASP论坛DIY


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-08-14   浏览: 52 ::
收藏到网摘: 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
%>