如何用Asp+Access制作简单的新闻发布
简简单单的,有发布,察看,修改,删除功能就可以了。网站上下的代码太复杂了,看不懂~~~~用附件发到我邮箱里~~~~谢谢!!!!我的邮箱:lm716@163.com...
简简单单的,有发布,察看,修改,删除功能就可以了。
网站上下的代码太复杂了,看不懂~~~~
用附件发到我邮箱里~~~~谢谢!!!!
我的邮箱:lm716@163.com 展开
网站上下的代码太复杂了,看不懂~~~~
用附件发到我邮箱里~~~~谢谢!!!!
我的邮箱:lm716@163.com 展开
展开全部
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
数据库连接文件(myconn.asp):
<%
dim conn '数据库连接
dim connstr '连接字符串
dim db '数据库文件路径
db = "qqchen.mdb"
connstr = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = " & Server.MapPath(db)
Set conn = Server.CreateObject("ADODB.Connection")
If Err Then
Err.Clear
Set Conn = Nothing
Response.Write "数据库连接出错,请打开conn.asp文件检查连接字串。"
Response.End
End If
conn.Open connstr
%>
'************************************************************
显示文章列表(articlelist.asp):
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="myconn.asp"-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>显示文章列表</title>
</head>
<body>
<div align="center">
<div align=left>◆<a href="addarticle.asp">发布新文章</a></div>
<table width="100%" border="0" cellspacing="1" bgcolor="#000000">
<tr>
<td width="7%" height="25" align="center" bgcolor="#FFFFFF"><strong>编号</strong></td>
<td width="51%" height="25" align="center" bgcolor="#FFFFFF"><strong>标题</strong></td>
<td width="20%" height="25" align="center" bgcolor="#FFFFFF"><strong>Nclassid</strong></td>
<td width="22%" height="25" align="center" bgcolor="#FFFFFF"><strong>操作</strong></td>
<%
Set Rs=conn.Execute("Select * From article Order By articleid")
If Not Rs.Eof Then
Do While Not Rs.Eof
%>
<tr>
<td align="center" bgcolor="#FFFFFF"><%=Rs("articleid")%></td>
<td align="center" bgcolor="#FFFFFF"><a href="showarticle.asp?articleid=<%=Rs("articleid")%>"><%=Rs("title")%></a></td>
<td align="center" bgcolor="#FFFFFF"><%=Rs("nclassid")%></td>
<td align="center" bgcolor="#FFFFFF"><a href="modifyarticle.asp?articleid=<%=Rs("articleid")%>">修改</a> | <a href="deletearticle.asp?articleid=<%=Rs("articleid")%>">删除</a></td>
</tr>
<%
Rs.Movenext
Loop
Else
%>
<tr>
<td colsapn=4 align="center" bgcolor="#FFFFFF"></td>
</tr>
<%End If%>
</table>
</div>
</body>
'************************************************************
显示文章信息(showarticle.asp):
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="myconn.asp"-->
<%
articleid=Cint(Request("articleid"))
If articleid>0 Then
Set Rs=conn.Execute("Select * From article Where articleid="&articleid)
conn.Execute("Update article Set hits=hits+1 Where articleid="&articleid)
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>阅读记录:<%=Rs("title")%></title>
</head>
<body>
<div align="center">
<table width="70%" border="1" cellpadding="4" cellspacing="0">
<tr>
<td width="19%" align="right">编号:</td>
<td width="81%" align="left"><%=Rs("articleid")%></td>
</tr>
<tr>
<td align="right">标题:</td>
<td align="left"><%=Rs("title")%></td>
</tr>
<tr>
<td align="right">nclassid:</td>
<td align="left"><%=Rs("nclassid")%></td>
</tr>
<tr>
<td align="right">classid:</td>
<td align="left"><%=Rs("classid")%></td>
</tr>
<tr>
<td align="right">浏览次数:</td>
<td align="left"><%=Rs("hits")%> 次</td>
</tr>
<tr>
<td align="right" valign="top">内容:</td>
<td align="left"><%=Rs("content")%></td>
</tr>
</table>
</div>
</body>
</html>
<%
Else
Response.Write "该文章不存在"
End If
%>
'************************************************************
添加文章信息(addarticle.asp):
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="myconn.asp"-->
<%
If Request.ServerVariables("REQUEST_METHOD")="POST" Then
content=Replace(Replace(Request("content")," "," "),chr(13),"<br>")
conn.Execute("Insert Into article(title,content,nclassid,classid) values('"&Request("title")&"','"& content &"',"&Request("nclassid")&","&Request("classid")&")")
Response.Redirect "articlelist.asp"
Else
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="?">
<table width="60%" border="1" cellpadding="4" cellspacing="0">
<tr>
<td align="right">标题:</td>
<td align="left"><input name="title" type="text" id="title"></td>
</tr>
<tr>
<td align="right">nclassid:</td>
<td align="left"><input name="nclassid" type="text" id="nclassid"" /></td>
</tr>
<tr>
<td align="right">classid:</td>
<td align="left"><input name="classid" type="text" id="classid"></td>
</tr>
<tr>
<td align="right">内容:</td>
<td align="left"><textarea name="content" cols="45" rows="10" id="content"></textarea></td>
</tr>
<tr>
<td align="right"> </td>
<td align="left"><input type="submit" name="Submit" value="修改" />
<input type="reset" name="Submit2" value="重置" />
<input type="button" name="Submit3" value="返回" onclick="history.back()"></td>
</tr>
</table>
</form>
</body>
</html>
<%End If%>
'************************************************************
修改文章信息(modifyarticle.asp):
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="myconn.asp"-->
<%
articleid=Cint(Request("articleid"))
If Request.ServerVariables("REQUEST_METHOD")="POST" Then
If articleid>0 Then
content=Replace(Replace(Request("content")," "," "),chr(13),"<br>")
conn.Execute("Update article Set title='"&Request("title")&"',content='"&content&"',nclassid="&Request("nclassid")&",classid="&Request("classid")&" Where articleid="&articleid)
Response.Redirect "articlelist.asp"
Else
Response.Write "该文章不存在"
End If
Else
If articleid>0 Then
Set Rs=conn.Execute("Select * From article Where articleid="&articleid)
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body>
<div align="center">
<form id="form1" name="form1" method="post" action="?articleid=<%=articleid%>">
<table width="60%" border="1" cellpadding="4" cellspacing="0">
<tr>
<td width="22%" align="right">编号:</td>
<td width="78%" align="left"><%=Rs("articleid")%></td>
</tr>
<tr>
<td align="right">标题:</td>
<td align="left"><input name="title" type="text" id="title" value="<%=Rs("title")%>" /></td>
</tr>
<tr>
<td align="right">nclassid:</td>
<td align="left"><input name="nclassid" type="text" id="nclassid" value="<%=Rs("nclassid")%>" /></td>
</tr>
<tr>
<td align="right">classid:</td>
<td align="left"><input name="classid" type="text" id="classid" value="<%=Rs("classid")%>" /></td>
</tr>
<tr>
<td align="right">内容:</td>
<td align="left"><textarea name="content" cols="45" rows="10" id="content"><%=Replace(Replace(Rs("content"),"<br>",chr(13))," "," ")%></textarea></td>
</tr>
<tr>
<td align="right"> </td>
<td align="left"><input type="submit" name="Submit" value="修改" />
<input type="reset" name="Submit2" value="重置" />
<input type="button" name="Submit3" value="返回" onclick="history.back()"></td>
</tr>
</table>
</form>
</div>
</body>
</html>
<%
Else
Response.Write "该文章不存在"
End If
End If
%>
'************************************************************
删除文章信息(deletearticle.asp):
<!--#include file="myconn.asp"-->
<%
articleid=Cint(Request("articleid"))
If articleid>0 Then
conn.Execute("Delete From article Where articleid="&articleid)
Response.Write "删除成功,<a href='articlelist.asp'>返回</a>"
Else
Response.Write "删除失败"
End If
%>
<%
dim conn '数据库连接
dim connstr '连接字符串
dim db '数据库文件路径
db = "qqchen.mdb"
connstr = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = " & Server.MapPath(db)
Set conn = Server.CreateObject("ADODB.Connection")
If Err Then
Err.Clear
Set Conn = Nothing
Response.Write "数据库连接出错,请打开conn.asp文件检查连接字串。"
Response.End
End If
conn.Open connstr
%>
'************************************************************
显示文章列表(articlelist.asp):
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="myconn.asp"-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>显示文章列表</title>
</head>
<body>
<div align="center">
<div align=left>◆<a href="addarticle.asp">发布新文章</a></div>
<table width="100%" border="0" cellspacing="1" bgcolor="#000000">
<tr>
<td width="7%" height="25" align="center" bgcolor="#FFFFFF"><strong>编号</strong></td>
<td width="51%" height="25" align="center" bgcolor="#FFFFFF"><strong>标题</strong></td>
<td width="20%" height="25" align="center" bgcolor="#FFFFFF"><strong>Nclassid</strong></td>
<td width="22%" height="25" align="center" bgcolor="#FFFFFF"><strong>操作</strong></td>
<%
Set Rs=conn.Execute("Select * From article Order By articleid")
If Not Rs.Eof Then
Do While Not Rs.Eof
%>
<tr>
<td align="center" bgcolor="#FFFFFF"><%=Rs("articleid")%></td>
<td align="center" bgcolor="#FFFFFF"><a href="showarticle.asp?articleid=<%=Rs("articleid")%>"><%=Rs("title")%></a></td>
<td align="center" bgcolor="#FFFFFF"><%=Rs("nclassid")%></td>
<td align="center" bgcolor="#FFFFFF"><a href="modifyarticle.asp?articleid=<%=Rs("articleid")%>">修改</a> | <a href="deletearticle.asp?articleid=<%=Rs("articleid")%>">删除</a></td>
</tr>
<%
Rs.Movenext
Loop
Else
%>
<tr>
<td colsapn=4 align="center" bgcolor="#FFFFFF"></td>
</tr>
<%End If%>
</table>
</div>
</body>
'************************************************************
显示文章信息(showarticle.asp):
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="myconn.asp"-->
<%
articleid=Cint(Request("articleid"))
If articleid>0 Then
Set Rs=conn.Execute("Select * From article Where articleid="&articleid)
conn.Execute("Update article Set hits=hits+1 Where articleid="&articleid)
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>阅读记录:<%=Rs("title")%></title>
</head>
<body>
<div align="center">
<table width="70%" border="1" cellpadding="4" cellspacing="0">
<tr>
<td width="19%" align="right">编号:</td>
<td width="81%" align="left"><%=Rs("articleid")%></td>
</tr>
<tr>
<td align="right">标题:</td>
<td align="left"><%=Rs("title")%></td>
</tr>
<tr>
<td align="right">nclassid:</td>
<td align="left"><%=Rs("nclassid")%></td>
</tr>
<tr>
<td align="right">classid:</td>
<td align="left"><%=Rs("classid")%></td>
</tr>
<tr>
<td align="right">浏览次数:</td>
<td align="left"><%=Rs("hits")%> 次</td>
</tr>
<tr>
<td align="right" valign="top">内容:</td>
<td align="left"><%=Rs("content")%></td>
</tr>
</table>
</div>
</body>
</html>
<%
Else
Response.Write "该文章不存在"
End If
%>
'************************************************************
添加文章信息(addarticle.asp):
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="myconn.asp"-->
<%
If Request.ServerVariables("REQUEST_METHOD")="POST" Then
content=Replace(Replace(Request("content")," "," "),chr(13),"<br>")
conn.Execute("Insert Into article(title,content,nclassid,classid) values('"&Request("title")&"','"& content &"',"&Request("nclassid")&","&Request("classid")&")")
Response.Redirect "articlelist.asp"
Else
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="?">
<table width="60%" border="1" cellpadding="4" cellspacing="0">
<tr>
<td align="right">标题:</td>
<td align="left"><input name="title" type="text" id="title"></td>
</tr>
<tr>
<td align="right">nclassid:</td>
<td align="left"><input name="nclassid" type="text" id="nclassid"" /></td>
</tr>
<tr>
<td align="right">classid:</td>
<td align="left"><input name="classid" type="text" id="classid"></td>
</tr>
<tr>
<td align="right">内容:</td>
<td align="left"><textarea name="content" cols="45" rows="10" id="content"></textarea></td>
</tr>
<tr>
<td align="right"> </td>
<td align="left"><input type="submit" name="Submit" value="修改" />
<input type="reset" name="Submit2" value="重置" />
<input type="button" name="Submit3" value="返回" onclick="history.back()"></td>
</tr>
</table>
</form>
</body>
</html>
<%End If%>
'************************************************************
修改文章信息(modifyarticle.asp):
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="myconn.asp"-->
<%
articleid=Cint(Request("articleid"))
If Request.ServerVariables("REQUEST_METHOD")="POST" Then
If articleid>0 Then
content=Replace(Replace(Request("content")," "," "),chr(13),"<br>")
conn.Execute("Update article Set title='"&Request("title")&"',content='"&content&"',nclassid="&Request("nclassid")&",classid="&Request("classid")&" Where articleid="&articleid)
Response.Redirect "articlelist.asp"
Else
Response.Write "该文章不存在"
End If
Else
If articleid>0 Then
Set Rs=conn.Execute("Select * From article Where articleid="&articleid)
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body>
<div align="center">
<form id="form1" name="form1" method="post" action="?articleid=<%=articleid%>">
<table width="60%" border="1" cellpadding="4" cellspacing="0">
<tr>
<td width="22%" align="right">编号:</td>
<td width="78%" align="left"><%=Rs("articleid")%></td>
</tr>
<tr>
<td align="right">标题:</td>
<td align="left"><input name="title" type="text" id="title" value="<%=Rs("title")%>" /></td>
</tr>
<tr>
<td align="right">nclassid:</td>
<td align="left"><input name="nclassid" type="text" id="nclassid" value="<%=Rs("nclassid")%>" /></td>
</tr>
<tr>
<td align="right">classid:</td>
<td align="left"><input name="classid" type="text" id="classid" value="<%=Rs("classid")%>" /></td>
</tr>
<tr>
<td align="right">内容:</td>
<td align="left"><textarea name="content" cols="45" rows="10" id="content"><%=Replace(Replace(Rs("content"),"<br>",chr(13))," "," ")%></textarea></td>
</tr>
<tr>
<td align="right"> </td>
<td align="left"><input type="submit" name="Submit" value="修改" />
<input type="reset" name="Submit2" value="重置" />
<input type="button" name="Submit3" value="返回" onclick="history.back()"></td>
</tr>
</table>
</form>
</div>
</body>
</html>
<%
Else
Response.Write "该文章不存在"
End If
End If
%>
'************************************************************
删除文章信息(deletearticle.asp):
<!--#include file="myconn.asp"-->
<%
articleid=Cint(Request("articleid"))
If articleid>0 Then
conn.Execute("Delete From article Where articleid="&articleid)
Response.Write "删除成功,<a href='articlelist.asp'>返回</a>"
Else
Response.Write "删除失败"
End If
%>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
看看
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
下载一个得了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询