标题: 简单ASP论坛DIY
France
中校
Rank: 1



UID 44418
精华 2
积分 1624
帖子 782
威望 6
金币 802
热心 0
阅读权限 50
注册 2007-2-18
状态 离线
简单ASP论坛DIY

阿泰的供稿
首先用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
  %>

顶部
[广告] 免费域名(Free Subdomain) 免费空间(Free hosting) PR查询(Google Pagerank)



当前时区 GMT+8, 现在时间是 2008-10-7 04:21
信产部ICP备案:京ICP备05066424号 北京市公安局网监备案:1101050648号

Powered by Discuz! 5.5.0
清除 Cookies - 联系我们 - 网友俱乐部 - Archiver - WAP