做毕业设计~求教:新闻系统中通过页面删除新闻的代码问题
包括2个文件,news.asp用来显示新闻列表,是用DW的重复区域做的,在每一条题目的后面有“删除”两字,这俩字链接到news_delete.asp,同时用一个session保存字段"title"的值,news_delete.asp通过接收session("title")来查找ACCESS数据库中表news的记录并进行删除操作,大体想法是这样,但运行后出现如下的错误提示:错误类型:
(0x80020009)
发生意外。
/bysj/news_delete.asp, 第 19 行
具体代码如下:
news.asp
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="Connections/bysj.asp" -->
<%
Dim Recordset1
Dim Recordset1_numRows
Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_bysj_STRING
Recordset1.Source = "SELECT * FROM news ORDER BY date DESC"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()
Recordset1_numRows = 0
%>-------------------------------------->新闻列表以时间降序排列
<form name="form" method="post" action="">
<%
While ((Repeat1__numRows <> 0) AND (NOT Recordset1.EOF))
%>
<table width="500" height="30" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="340" height="30" align="left" valign="middle"><%=(Recordset1.Fields.Item("title").Value)%></td>
<td width="80" height="30" align="center" valign="middle"><a href="<%=(Recordset1.Fields.Item("content").Value)%>" class="link">查看</a></td>
<td width="80" height="30" align="center" valign="middle"><a href="admin_newsdelete.asp" class="link">删除</a></td>
</tr>
</table>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
Recordset1.MoveNext()
Wend
%>
</form>-------------------------------------->这是显示新闻列表的表格(只有一行,设置为重复区域)
<%
session("title")=Recordset1.fields.item("title").value
%>-------------------------------------------------->将title存入session
下面是news_delete.asp:
<% @language="vbscript" %>
<%
response.buffer=true
Response.Expires=0
%>
<%
dim title
title=session("title")
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("db.mdb")
sql="select * from news where title = '"& title &"' "
Set rs = Server.CreateObject("ADODB.Recordset")
rs.open sql,conn,3,3
while not rs.eof
if rs("title")=title then
rs.delete
rs.update
else
rs.movenext
end if
wend
rs.close
set rs=nothing
sub CloseConn()
conn.close
set conn=nothing
end sub
response.write"<script>alert('删除成功');location.href='admin_news.asp'</script>"
%>