文谷首页 | 业界传真 | 网络技术 | 服务器 | 数据库 | 存储技术 | 系统安全 | 无线技术 | Cisco | .Net | Windows | Linux | Unix | Java
电子商务 | 网站工程 | 网页设计 | 平面设计 | 多媒体 | 编程语言 | Oracle | MSSQL | Photoshop | ASP | PHP | 实用技巧 | 进程查询 | 文谷论坛
 Sybase   Oracle   SQL server   Informix   MySQL   Access   VFP   DB2   PostgreSQL   其它数据库
您现在的位置: IT文谷 >> 数据库技术 >> Access >> 文章正文
用Access制作一个功能完善的论坛(源程序)2006-3-26 13:17:54用Access制作一个功能完善的论坛(源程序)2006-3-26 13:17:54用Access制作一个功能完善的论坛(源程序)
用Access制作一个功能完善的论坛(源程序)2006-3-26 13:17:54用Access制作一个功能完善的论坛(源程序)2006-3-26 13:17:54用Access制作一个功能完善的论坛(源程序)
用Access制作一个功能完善的论坛(源程序)

用Access制作一个功能完善的论坛(源程序)2006-3-26 13:17:54用Access制作一个功能完善的论坛(源程序)2006-3-26 13:17:54用Access制作一个功能完善的论坛(源程序)
To view a live demonstration of this forum, click View Demo.
To create this forum on your server, you will need to create a Microsoft Access Database named
discuss.mdb. You will also need to create a single table in this database named messages that has the
following fields:

m_id -- An autonumber field
m_email -- A text field
m_subject -- A text field
m_message -- A Memo field
m_entrydate -- A Date/Time field with default value of NOW()
m_numReplies -- A Number field with default value of 0
m_reply -- A Number field with default value of -1




Listing 1.0 - discuss.asp

-----------------------------------
<html>
<head><title>Discussion</title></head>
<frameset rows="30,*">
<frame frameborder="no" scrolling="no" src="discusslogo.asp" marginheight=2 marginwidth=5>
<frame name="topframe" src="discussframes.asp">
</frameset>
</html>
-----------------------------------------









Listing 2.0 - discussframes.asp
-------------------------------------------------
<!-- #INCLUDE FILE="discussfuncs.asp" -->
<%
page = TRIM( request( "pg" ) )
addm = TRIM( request( "addm" ) )
email = TRIM( request( "email" ) )
subject = TRIM( request( "subject" ) )
message = TRIM( request( "message" ) )

IF addm <> "" THEN
IF email = "" THEN
showError "You did not enter your email address", "post.asp"
END IF
IF subject = "" THEN
showError "You did not enter a subject for your message", "post.asp"
END IF
IF message = "" THEN
showError "You did not enter a message", "post.asp"
END IF
IF INSTR( email, "." ) = 0 OR INSTR( email, "@" ) = 0 THEN
showError "You did not enter a valid email address", "post.asp"
END IF


readyDBCon
Set RS = Server.CreateObject( "ADODB.Recordset" )
RS.ActiveConnection = Con
RS.CursorType = adOpenStatic
RS.LockType = adLockOptimistic
RS.Open "SELECT * FROM messages WHERE 1<>1", Con
RS.AddNew
RS( "m_email" ) = email
RS( "m_subject" ) = subject
RS( "m_message" ) = message
RS( "m_reply" ) = addm
RS.Update
RS.Close
IF addm <> "-1" THEN
Con.Execute "UPDATE messages SET m_numreplies = m_numreplies+1 WHERE m_id=" & addm
END IF
END IF
%>
<html>
<head><title>frameset</title>
<frameset rows="300,*">
<frame marginheight="3" marginwidth="5" frameborder="no" scrolling="yes" src="messagelist.asp?
pg=<%=page%>">
<frame name="message" marginwidth="0" marginheight="0" frameborder="no" scrolling="auto"
src="message.asp?id=<%=addm%>&pg=<%=page%>">
</frameset>
</html>

------------------------------------------------------







Listing 3.0 - discussfuncs.asp
-------------------------------------------------------
<%
dbPath = "d:discuss.mdb"
messagesApage = 5

''''''''''
' Define Constants  
''''''''''
adOpenStatic = 3
adLockOptimistic = 3


''''''''''''''
' Declare Global Variables
''''''''''''''
DIM Con


SUB readyDBCon
IF Con = "" THEN
Set Con = Server.CreateObject( "adodb.Connection" )
Con.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & dbPath
END IF
END SUB



FUNCTION showUser( theEmail )
whereA = INSTR( theEmail, "@" )
showUser = Server.HTMLEncode( LEFT( theEmail, whereA - 1 ) )
END FUNCTION



FUNCTION formatOutput( theText )
theText = Server.HTMLEncode( theText )
theText = REPLACE( theText, vbNewline & vbNewline, "<p>" )
theText = REPLACE( theText, vbNewline, "<br>" )
formatOutput = theText
END FUNCTION



sub showError( errorMessage, backpage )
%>
<html>
<head><title>Problem</title></head>
<body bgcolor="lightyellow">
<center>
<table width="400" border=0 cellpadding=4 cellspacing=0>
<tr>
<td>
<font face="Arial" size="4" color="red"><b>
There was a problem with the message you entered:</b></font>
<p><font face="Arial" size="3" color="blue"><b>
<%=errorMessage%>. Please click the button below to correct this problem</b></font>
<form method="post" action="<%=backpage%>">
<%
for each thing in Request.Form
%>
<input name="<%=thing%>" type="hidden" value="<%=Server.HTMLEncode( Request(
thing ) )%>">
<%
next
%>
<input type="submit" value="Back">
</form>

</td>
</tr>
</table>
</body>
</head>
<%
Response.End
end sub
%>









Listing 4.0 - discusslogo.asp
-------------------------------------------
<html>
<head><title>logo</title></head>
<body bgcolor="darkgreen" marginheight=0 topmargin=0>

<table border=0 cellpadding=0 cellspacing=0 width="100%">
<tr>
<td>
<font face="Arial" size="2" color="#ffffff"><b>Microsoft Access Forum</b></font>
</td>
</tr>
</table>

</body>
</html>













Listing 5.0 - message.asp
------------------------------------
<!-- #INCLUDE FILE="discussfuncs.asp" -->
<%
id = TRIM( Request( "id" ) )
IF id = "-1" THEN id = ""

page = TRIM( Request( "pg" ) )
%>

<html>
<head><title>message</title></head>
<body bgcolor="#ffffff">

<%
IF id = "" THEN
%>
<table width="100%" height="100%" cellpadding=0 cellspacing=0 border=0>
<tr>
<td valign="center" align="center">
<font face="Arial" size="3" color="blue">
<b>Select a message to read by clicking on one of the subjects above</b>
</font>
</td>
</tr>
</table>
<%
ELSE
readyDBCon
SET RS = Server.CreateObject( "ADODB.Recordset" )
RS.ActiveConnection = Con
RS.CursorType = adOpenStatic
RS.Open "select * FROM messages WHERE m_id=" & id & " OR m_reply=" & id & " order by m_id"
mCount = 0
WHILE NOT RS.EOF
%>
<table width="100%" border=0 cellpadding=2 cellspacing=0 bgcolor="yellow">
<tr>
<td>
<b>Author:</b> <%=showUser( RS( "m_email" ) )%>
</td>
<td align="right">
<b>Date Posted:</b> <%=RS( "m_entrydate" )%>
</td>
</tr>
<tr>
<td colspan=2>
<b>Subject:</b> <%=Server.HTMLEncode( RS( "m_subject" ) )%>
</td>
</tr>
</table>
<table width="100%" cellpadding=4 cellspacing=0 border=0>
<tr>
<td>
<font face="Arial" size="2">
<%=formatOutput( RS( "m_message" ) )%>
</font>
<P>
<a href="post.asp?id=<%=id%>&pg=<%=page%>" target="topframe">Reply To This
Message</a>
</td>
</tr>
</table>
<% if mcount = 0 THEN %>
<a name="replies"> </a>
<% END IF %>
<%
RS.MoveNext
WEND
END IF
%>

</body>
</html>
----------------------------------------













Listing 6.0 - messagelist.asp
-------------------------------------------
<!-- #INCLUDE FILE="discussfuncs.asp" -->
<html>
<head><title>Message List</title></head>
<body bgcolor="#eeeeee">


<table width="100%" border=0 cellpadding=4 cellspacing=0>
<tr>
<td align="right">
<a href="post.asp" target="topframe"><font face="Arial" size="2"><i>Post New
Message</i></font></a>  
</td>
</tr>
</table>

<%
page = Request( "pg" )
IF page = "" THEN page = 1


readydbCon

SET RS = Server.CreateObject( "ADODB.Recordset" )
RS.ActiveConnection = Con
RS.CursorType = adOpenStatic
RS.Open "select m_id, m_email, m_subject, m_numreplies, m_entrydate FROM messages WHERE m_reply=-1 ORDER
by m_id DESC"
RS.PageSize = messagesApage
RS.AbsolutePage = page
IF RS.EOF THEN
%>
<font face="Arial">There are no messages</font>
<%
ELSE
%>
<table width="100%" border=0 cellpadding=4 cellspacing=0>
<tr>
<td>
<font size="2" color="darkgreen"><b>AUTHOR</b></font>
</td>
<td>
<font size="2" color="darkgreen"><b>SUBJECT</b></font>
</td>
<td>
<font size="2" color="darkgreen"><b>REPLIES</b></font>
</td>
<td>
<font size="2" color="darkgreen"><b>DATE POSTED</b></font>
</td>
</tr>
<%
WHILE NOT RS.EOF and counter < RS.PageSize
%>
<tr>
<td><font size="2" ><%=showUser( RS( "m_email" ) )%></font></td>
<td><a href="message.asp?id=<%=RS( "m_id" )%>&pg=<%=page%>" target="message"><font
size="2">&l
用Access制作一个功能完善的论坛(源程序)2006-3-26 13:17:54用Access制作一个功能完善的论坛(源程序)2006-3-26 13:17:54用Access制作一个功能完善的论坛(源程序)
  • 上一篇文章:

  • 下一篇文章:
  • 进入论坛讨论

    相关文章
    _disable_logging对于性能的影响
    针对Oracle数据库的优化器详细介绍
    索引与Null值对于Hints及执行计划的影响
    了解 Oracle ADF:入门示例
    DataGuard数据库服务器硬盘故障处理
    用sql比较两个数据库是否一致
    用触发器生成数据库表的数据操作日志
    查询Oracle各组件的版本信息
    Oracle入门基础:绑定变量测试
    Oracle的db_name和instance_name
    一个容易忽视的Oracle数据安全问题
    Oracle时间信息特性
    热门文章最新推荐

    版权与免责声明:
    ① 本网转载其他媒体稿件是为传播更多的信息,此类稿件不代表本网观点,版权归原作者所有,本网不承担此类稿件侵权行为的连带责任。
    ② 在本网BBS上发表言论者,文责自负。
    ③ 如您因版权等问题需要与本网联络,请在30日内联系 。
    用Access制作一个功能完善的论坛(源程序)2006-3-26 13:17:54用Access制作一个功能完善的论坛(源程序)2006-3-26 13:17:54用Access制作一个功能完善的论坛(源程序)
    用Access制作一个功能完善的论坛(源程序)2006-3-26 13:17:54用Access制作一个功能完善的论坛(源程序)2006-3-26 13:17:54用Access制作一个功能完善的论坛(源程序)

    数据库专题
    人气排行
    普通文章SQL Server数据库的备份与恢
    普通文章从MDF文件恢复Sql Server200
    普通文章SQL中,单引号与&等特殊符号
    普通文章SQL Server定期自动备份
    普通文章通过ODBC连接的SQL SERVER实
    普通文章SQL入门:删除数据
    普通文章sqlldr的用法总结
    普通文章XP下access数据不能更新,数据
    普通文章在SQL Server的存储过程中调
    普通文章SQL Server的有效安装
    最近更新
    推荐文章如何恢复/修复MS SQL数据库的
    普通文章Mysql和phpMyAdmin的设置
    普通文章phpmyadmin设置和常见问题
    普通文章PhpMyAdmin配置示例
    普通文章php+mysql中文乱码的解决
    普通文章phpmyadmin配置
    推荐文章Oracle函数列表速查
    普通文章_disable_logging对于性能的
    普通文章针对Oracle数据库的优化器详
    普通文章索引与Null值对于Hints及执行
    全站热点       
    最新推荐
    关于文谷 | 联系文谷 | 免责声明 | 文谷论坛
    Tel: 0577-65690019      E-mail: ichenjian@gmail.com    MSN:ichenjian@hotmail.com    QQ:2911194
    Copyright © 2004-2008 wengu.com 文谷 All Rights Reserved
    浙ICP备05000327号