我们有一个旧网站给我们一个错误。它使用 VBScript,数据库是 SQL Server 2005。
这是代码:
set oNotes = server.CreateObject("SCRIPTING.DICTIONARY")
openSQL "SELECT * FROM v_client_notes WHERE contact_id = " &_
my_contactID & " ORDER BY client_notes_duedate ASC"
do while rs.eof = false
set temp = server.CreateObject("SCRIPTING.DICTIONARY")
load_rs temp, rs
set oNotes(trim(rs("client_notes_id"))) = temp
rs.movenext'error on this line
loop
错误:
用于 SQL Server 错误“80040e23”的 Microsoft OLE DB 提供程序
行句柄指的是已删除的行或标记为删除的行。
此错误并非一直发生,仅针对带有某些contact_id 返回的记录集。无法确定有效和无效的区别。
如您所见,错误发生在 rs.movenext 上。
我已确保该表具有主键 (client_notes_id)。
感谢您的帮助!
编辑
这是 load_rs 的代码:
function load_rs(dict,Byref record)
for each thing_record in record.fields
dict(thing_record.name) = trim(thing_record.value)
next
end function
这是更新脚本。这是在我发布到的单独页面上(有点 AJAX 风格):
If request("client_notes") <> "" then
client_notes_subject = request("client_notes_subject")
client_notes_postedby = session("user")
client_notes_duedate = request("client_notes_duedate")
if client_notes_duedate = "" then
client_notes_duedate = NULL
end if
client_notes_date_entered = request("client_notes_date_entered")
client_notes = request("client_notes")
if isnumeric(request("contactID")) then contact_id = request("contactID")
if clientnotes_id="" then clientnotes_id="0"
openSQL("SELECT * FROM client_notes WHERE client_notes_id=" & clientnotes_id)
if rs.EOF then
openSQL("SELECT newid()")
client_notes_guid = rs(0)
openSQL("select * from client_notes")
rs.addnew
else
client_notes_guid = rs("guid")
rs.update
end if
rs("contact_id") = contact_id
rs("client_notes_subject") = client_notes_subject
rs("client_notes_postedby") = session("user")
'if client_notes_duedate <> Null then
rs("client_notes_duedate") = client_notes_duedate
'end if
rs("client_notes_date_entered") = client_notes_date_entered
rs("client_notes") = client_notes
rs("guid")=client_notes_guid
rs.update
'if client_notes_duedate = Null then
' sqlSetNullnotes = "UPDATE client_notes SET client_notes_duedate = NULL WHERE client_notes_id=" & clientnotes_id
' opensql sqlSetNullnotes
'end if
next_due_date = request("next_due_date")
if next_due_date = "" then
next_due_date = NULL
end if
openSQL("SELECT * FROM " & MainContactsDB & " WHERE Contact_ID=" & contactID)
rs("Last_Contact_Date") = client_notes_date_entered
rs("Next_Contact_Date") = next_due_date
rs.update
end if
开放SQL方法:
Set rs = Server.CreateObject("ADODB.Recordset")
function openSQL(SQLrs)
if rs.state = 1 then rs.close
'response.write sqlRS
rs.Open SQLrs, conn, 3, 3
end function