0

错误提示:BOF 或 EOF 为 True,或者当前记录已被删除。请求的操作需要当前记录。

我有从另一个站点接收 id 的代码,它是一个数字,并将编辑与 id 匹配的数据。

<body>    
<table style="width: 100%">
    <tr>
    <!-- #include file="header.html"-->
        </tr>
</table>
<table>
<tr >
<td style="width:885px" class="style2" >
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "C:\inetpub\wwwroot\library\database.mdb"
cid=Request.Form("number")
if Request.form("firstname")="" then
set rs=Server.CreateObject("ADODB.Recordset")

  rs.open "SELECT * FROM users WHERE no='" & cid & "'",conn
  %>
<form method="post" action="change.asp">
<table>
  <%for each x in rs.Fields%>
  <tr>
  <td><% Response.Write(x.name)%></td>
  <td><input name='<%Response.Write(x.name)%>' value='<%Response.Write(x.value)%>'></td>
  <%next%>
  </tr>
  </table>
    <br /><br />
  <input type="submit" value="Update record">
  </form>
<%
else
    sql="UPDATE users SET "
    sql=sql & "firstname='" & Request.Form("firstname") & "',"
    sql=sql & "lastname='" & Request.Form("lastname") & "',"
    sql=sql & "Gender='" & Request.Form("Gender") & "'"
  sql=sql & " WHERE no='" & cid & "'"
  on error resume next
  conn.Execute sql
  if err<>0 then
    response.write("No update permissions!")
  else
    response.write("Record " & cid & " was updated!")
  end if
end if
conn.close
%>


</td>
<td><!--#include file="sideMenu.html"-->
</td>
</tr>
</table>
</body>
4

2 回答 2

1
  <body>    
  <table style="width: 100%">
      <tr>
      <!-- #include file="header.html"-->
          </tr>
  </table>
  <table>
  <tr >
  <td style="width:885px" class="style2" >
  <%
  set conn=Server.CreateObject("ADODB.Connection")
  conn.Provider="Microsoft.Jet.OLEDB.4.0"
  conn.Open "C:\inetpub\wwwroot\library\database.mdb"
  cid=Request.Form("number")
  if Request.form("firstname")="" then
  set rs=Server.CreateObject("ADODB.Recordset")

    rs.open "SELECT * FROM users WHERE no=" & cid ,conn

    If rs.EOF Then

       Response.Write "There is no data for this user in the database"

    Else

    %>
  <form method="post" action="change.asp">
  <table>

    <%for each x in rs.Fields%>
     <tr>
       <td><%=x.name%></td>
       <td><input name='<%=x.name%>' value='<%=x.value%>'></td>
     </tr>          
    <%next%>        

  </table>
      <br /><br />
    <input type="submit" value="Update record">
    </form>
  <%

  End If

  rs.Close
  Set rs = Nothing

  else
      sql="UPDATE users SET "
      sql=sql & "firstname='" & Request.Form("firstname") & "',"
      sql=sql & "lastname='" & Request.Form("lastname") & "',"
      sql=sql & "Gender='" & Request.Form("Gender") & "'"
    sql=sql & " WHERE no=" & cid
    on error resume next
    conn.Execute sql
    if err<>0 then
      response.write("No update permissions!")
    else
      response.write("Record " & cid & " was updated!")
    end if
  end if
  conn.close
  %>


  </td>
  <td><!--#include file="sideMenu.html"-->
  </td>
  </tr>
  </table>
  </body>
于 2012-07-03T02:01:38.080 回答
0

权限问题?检查 IIs 是否有权读取数据库表。此外,在这一行

if Request.form("firstname")="" then

我通常使用

if Request.form("firstname") & ""="" then
于 2012-07-07T22:14:43.403 回答