求助!!!!!BOF 或 EOF 中有一个是“真”,或者当前的记录已被删除,所需的操作要求一个当前的记录。
问题:<Script error detected at line 21. Source line: rs("Sname")=strName
Description: BOF 或 EOF 中有一个是“真”,或者当前的记录已被删除,所需的操作要求一个当前的记录。>
程序:modifyshoplist.asp
程序代码:
<% DbPath = SERVER.MapPath("database/Dysy.mdb") Set conn = Server.CreateObject("ADODB.Connection") 'conn.open"driver={Microsoft Access driver (*.mdb)};dbq =" & DbPath conn.connectionstring="driver={Microsoft Access driver (*.mdb)};dbq=" & Server.MapPath("database/Dysy.mdb") conn.open set rs=server.CreateObject("adodb.recordset") rs.ActiveConnection =conn sql="select * from shopinfo order by Sid" rs.open sql,,1,1 %> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>小说数据修改</title> <style type="text/css"> <!-- body,td,th { font-size: 12px; } body { background-color: #DFEEFF; } .style3 {color: #FFFFFF} --> </style></head> <body> <form name="form2" method="post" action=""> <table width="90%" border="1" align="center" cellspacing="2" bordercolor=green> <caption> <h3 align=center><u>商品信息修改</u></h3> </caption> <tr> <td width="94%"> <table width="100%" border="1" align="center" cellspacing="2" bordercolor="gray" class="table"> <tr bordercolor="#ffffff" cellpadding="0"> <th align="center">序号</th> <th align="center">商品名</th> <th align="center">商品类型</th> <th align="center">商品价格</th> <th align="center">商品数量</th> <th align="center">商品图片</th> <th align="center">操作</th> </tr> <% if not rs.eof then tol=rs.recordcount rs.pagesize=5 maxpage=rs.pagecount requestpage=clng(request("p")) if requestpage="" or requestpage=0 then requestpage=1 end if if requestpage>maxpage then requestpage=maxpage end if if requestpage<>1 then rs.move (requestpage-1)*rs.pagesize end if for i=1 to rs.pagesize if i mod 2=1 then bg="#FFFFFF" else bg="#efefef" end if%> <tr align="center" bgcolor=<%=bg%> style="cursor:hand"> <td height="22"><%=rs("Sid")%> <td><%=rs("Sname")%></td> <td><%=rs("Stype")%></td> <td><%=rs("Sprice")%></td> <td><%=rs("Snum")%></td> <td><%=rs("Simgpath")%></td> <td><a href="modifyshop.asp?name=<%=rs("Sname")%>">修改</a></td> </tr> <% rs.movenext if rs.eof then exit for next else response.Write("数据库中没有数据!无法浏览!") end if%> </table></td> </tr> </table> <table width="90%" border="0" align="center"> <tr> <td width="63%" align="right"> <a href="index.asp" target="_blank">返回首页</a> <a href="modifyshoplist.asp?p=1">首页</a> <a href="modifyshoplist.asp?p=<%=requestpage-1%>">上一页</a> <a href="modifyshoplist.asp?p=<%=requestpage+1%>">下一页</a> <a href="modifyshoplist.asp?p=<%=maxpage%>">最后一页</a> 当前页:<%=requestpage%> 总页数:<%=maxpage%> 总商品数:<%=tol%> 每页显示5条信息</td> </tr> </table> </form> </body> </html>
程序代码:
modifyshop.asp <% DbPath = SERVER.MapPath("database/Dysy.mdb") Set conn = Server.CreateObject("ADODB.Connection") 'conn.open"driver={Microsoft Access driver (*.mdb)};dbq =" & DbPath conn.connectionstring="driver={Microsoft Access driver (*.mdb)};dbq=" & Server.MapPath("database/Dysy.mdb") conn.open set rs=server.CreateObject("adodb.recordset") rs.ActiveConnection =conn strName=Request.QueryString("name") sql="select * from shopinfo where Sname='" &strName& "'" rs.Open sql,,1,1 if Request.ServerVariables("Request_Method")="POST" then ' rs.Close strName=Request.Form("txtName") strType=Request.Form("txtType") strPrice=Request.Form("txtPrice") strNum=Request.Form("txtNum") strImgpath=Request.Form("txtImgpath") sql="select * from shopinfo where Sname='" & strName & "'" 'Response.Write "sql=" & sql rs.Open sql,,1,3 rs("Sname")=strName rs("Stype")=strType rs("Sprice")=strPrice rs("Snum")=strNum rs("Simgpath")=strImgpath rs.Update rs.Close Response.Write "<center>数据修改成功!<a href='modifyshoplist.asp'>单击此处继续修改数据!</a></center>" Response.End end if %> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>商品信息修改</title> <style type="text/css"> <!-- body,td,th { font-size: 12px; } body { background-color: #DFEEFF; } .style3 {color: #FFFFFF} --> </style></head> <body> <form name="form2" method="post" action="modifyshop.asp"> <table width="60%" border="1" align="center" cellspacing="2" bordercolor=green> <caption> <h3 align=center><u>商品信息修改</u></h3> </caption> <tr> <td> <table width="100%" border="1" align="center" cellspacing="2" bordercolor="gray" class="table"> <tr bordercolor="#ffffff" cellpadding="0"> <th align="center">序 号</th> <td><INPUT type="text" name="txtSid" value="<%=Rs("Sid")%>" disabled></td> </tr> <tr bordercolor="#ffffff" cellpadding="0"> <th align="center">商品名称</th> <td><INPUT type="text" name="txtName" value="<%=Rs("Sname")%>"></td> </tr> <tr bordercolor="#ffffff" cellpadding="0"> <th align="center">商品类型</th> <td><INPUT type="text" name="txtType" value="<%=Rs("Stype")%>"></td> </tr> <tr bordercolor="#ffffff" cellpadding="0"> <th align="center">商品价格</th> <td><INPUT type="text" name="txtPrice" value="<%=Rs("Sprice")%>"></td> </tr> <tr bordercolor="#ffffff" cellpadding="0"> <th align="center">商品数量</th> <td><INPUT type="text" name=txtNum value="<%=Rs("Snum")%>"></td> </tr> <tr bordercolor="#ffffff" cellpadding="0"> <th align="center">商品图片</th> <td><INPUT type="text" name="txtImgpath" value="<%=Rs("Simgpath")%>"></td> </tr> <tr bordercolor="#ffffff" cellpadding="0"> <td colspan=2 align=center><INPUT type="button" value="提交" name=cmdOk><INPUT type="reset" value="重置" name=reset1></td> </tr> </table></td> </tr> </table> </form> </body> </html> <script language="VBscript"> sub cmdOk_onclick strName=trim(form2.txtName.value) strType=trim(form2.txtType.value) strPrice=trim(form2.txtPrice.value) strNum=trim(form2.txtNum.value) strImgpath=trim(form2.txtImgpath.value) if strName="" or strType=""or strPrice=""or strNum=""or strImgpath="" then msgbox "所有数据不能为空!",,"警告" exit sub end if form2.submit end sub </script>