回 帖 发 新 帖 刷新版面

主题:关于更新纪录的问题,与删除的问题怎么不行呀?

ADODB.Field (0x800A0BCD)
BOF 或 EOF 中有一个是“真”,或者当前的记录已被删除,所需的操作要求一个当前的记录。
/detailstu.asp, 第 99 行

回复列表 (共4个回复)

沙发

代码:
<form id="form1" name="form1" method="post" action="">
  <table width="750" border="1">
    <tr>
      <td width="92" align="right">学号</td>
      <td width="642"><label><%=(detail.Fields.Item("id").Value)%>      </label></td>
    </tr>
    <tr>
      <td align="right">姓名</td>
      <td><label><%=(detail.Fields.Item("name").Value)%></label></td>
    </tr>
    <tr>
      <td align="right">性别</td>
      <td><%=(detail.Fields.Item("sex").Value)%></td>
    </tr>
    <tr>
      <td align="right">年龄</td>
      <td><label><%=(detail.Fields.Item("age").Value)%></label></td>
    </tr>
    <tr>
      <td align="right">宿舍号</td>
      <td><label><%=(detail.Fields.Item("dorm").Value)%></label></td>
    </tr>
    <tr>
      <td align="right">电话</td>
      <td><label><%=(detail.Fields.Item("phone").Value)%></label></td>
    </tr>
  </table>
</form>

板凳

<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="Connections/kevin.asp" -->
<%
Dim detail__MMColParam
detail__MMColParam = "1"
If (Request.QueryString("id") <> "") Then 
  detail__MMColParam = Request.QueryString("id")
End If
%>
<%
Dim detail
Dim detail_numRows

Set detail = Server.CreateObject("ADODB.Recordset")
detail.ActiveConnection = MM_kevin_STRING
detail.Source = "SELECT * FROM student WHERE id = '" + Replace(detail__MMColParam, "'", "''") + "'"
detail.CursorType = 0
detail.CursorLocation = 2
detail.LockType = 1
detail.Open()

detail_numRows = 0
%>
<%
Dim MM_paramName 
%>
<%
' *** Go To Record and Move To Record: create strings for maintaining URL and Form parameters

Dim MM_keepNone
Dim MM_keepURL
Dim MM_keepForm
Dim MM_keepBoth

Dim MM_removeList
Dim MM_item
Dim MM_nextItem

' create the list of parameters which should not be maintained
MM_removeList = "&index="
If (MM_paramName <> "") Then
  MM_removeList = MM_removeList & "&" & MM_paramName & "="
End If

MM_keepURL=""
MM_keepForm=""
MM_keepBoth=""
MM_keepNone=""

' add the URL parameters to the MM_keepURL string
For Each MM_item In Request.QueryString
  MM_nextItem = "&" & MM_item & "="
  If (InStr(1,MM_removeList,MM_nextItem,1) = 0) Then
    MM_keepURL = MM_keepURL & MM_nextItem & Server.URLencode(Request.QueryString(MM_item))
  End If
Next

' add the Form variables to the MM_keepForm string
For Each MM_item In Request.Form
  MM_nextItem = "&" & MM_item & "="
  If (InStr(1,MM_removeList,MM_nextItem,1) = 0) Then
    MM_keepForm = MM_keepForm & MM_nextItem & Server.URLencode(Request.Form(MM_item))
  End If
Next

' create the Form + URL string and remove the intial '&' from each of the strings
MM_keepBoth = MM_keepURL & MM_keepForm
If (MM_keepBoth <> "") Then 
  MM_keepBoth = Right(MM_keepBoth, Len(MM_keepBoth) - 1)
End If
If (MM_keepURL <> "")  Then
  MM_keepURL  = Right(MM_keepURL, Len(MM_keepURL) - 1)
End If
If (MM_keepForm <> "") Then
  MM_keepForm = Right(MM_keepForm, Len(MM_keepForm) - 1)
End If

' a utility function used for adding additional parameters to these strings
Function MM_joinChar(firstItem)
  If (firstItem <> "") Then
    MM_joinChar = "&"
  Else
    MM_joinChar = ""
  End If
End Function
%>
<!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>

3 楼

你的表里面没有记录,你最好使用
if rs.eof() and rs.eof()
来判断是否有记录才继续操作
不然,没有记录的时候就要报错!

4 楼

应该是表文件没有记录才有的错误..

我来回复

您尚未登录,请登录后再回复。点此登录或注册