BOF 或 EOF 中有一个是“真”,或者当前的记录已被删除,所需的操作要求一个当前的记录。 5
<%@LANGUAGE="VBSCRIPT"CODEPAGE="936"%><!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.01Transiti...
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>远程教育系统</title>
<% dim i
dim cnn
dim strcnn
Set cnn=Server.CreateObject("ADODB.Connection")
strcnn="provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath("新闻发布系统/db.mdb")
cnn.Open strcnn
dim str
dim rs
if request.ServerVariables("CONTENT_LENGTH")=0 then
session("id")=request("id")
end if
str="select * from news where id="& session("id")
Set rs=Server.CreateObject("ADODB.recordset")
rs.open strcnn,3,3
if request.ServerVariables("CONTENT_LENGTH")<>0 then
rs("news_title")=request("news_title")
rs("news_type")=trim(request.form("news_type"))
rs("news_editer")=trim(request.form("news_editer"))
rs("news_url")=trim(request.form("news_url"))
rs("news_content")=trim(request.form("news_content"))
rs("news_fileurl")=trim(request.form("news_fileurl"))
rs.update
response.Write "恭喜你!您修改成功!"
cnn.close
response.Redirect("webadmin.asp")
set rs = nothing
set cnn = nothing
Set rstest = nothing
end if
%>
<SCRIPT LANGUAGE="VBSCRIPT">
<!--
sub add()
document.form1.submit
end sub 展开
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>远程教育系统</title>
<% dim i
dim cnn
dim strcnn
Set cnn=Server.CreateObject("ADODB.Connection")
strcnn="provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath("新闻发布系统/db.mdb")
cnn.Open strcnn
dim str
dim rs
if request.ServerVariables("CONTENT_LENGTH")=0 then
session("id")=request("id")
end if
str="select * from news where id="& session("id")
Set rs=Server.CreateObject("ADODB.recordset")
rs.open strcnn,3,3
if request.ServerVariables("CONTENT_LENGTH")<>0 then
rs("news_title")=request("news_title")
rs("news_type")=trim(request.form("news_type"))
rs("news_editer")=trim(request.form("news_editer"))
rs("news_url")=trim(request.form("news_url"))
rs("news_content")=trim(request.form("news_content"))
rs("news_fileurl")=trim(request.form("news_fileurl"))
rs.update
response.Write "恭喜你!您修改成功!"
cnn.close
response.Redirect("webadmin.asp")
set rs = nothing
set cnn = nothing
Set rstest = nothing
end if
%>
<SCRIPT LANGUAGE="VBSCRIPT">
<!--
sub add()
document.form1.submit
end sub 展开
展开全部
rs.open strcnn,3,3 这句之后加个错误处理
if rs.eof or rs.bof then
response.write "错误的id"
else
if request.ServerVariables("CONTENT_LENGTH")<>0 then
rs("news_title")=request("news_title")
rs("news_type")=trim(request.form("news_type"))
rs("news_editer")=trim(request.form("news_editer"))
rs("news_url")=trim(request.form("news_url"))
rs("news_content")=trim(request.form("news_content"))
rs("news_fileurl")=trim(request.form("news_fileurl"))
rs.update
end if
错误原因 查询出来没有对应的数据记录,可能session("id")没有值,或者数据库里的类型不对。
if rs.eof or rs.bof then
response.write "错误的id"
else
if request.ServerVariables("CONTENT_LENGTH")<>0 then
rs("news_title")=request("news_title")
rs("news_type")=trim(request.form("news_type"))
rs("news_editer")=trim(request.form("news_editer"))
rs("news_url")=trim(request.form("news_url"))
rs("news_content")=trim(request.form("news_content"))
rs("news_fileurl")=trim(request.form("news_fileurl"))
rs.update
end if
错误原因 查询出来没有对应的数据记录,可能session("id")没有值,或者数据库里的类型不对。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询