We have an old site that is giving us an error. It uses VBScript and the DB is SQL Server 2005.
Here is the code:
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
Error:
Microsoft OLE DB Provider for SQL Server error ‘80040e23’
Row handle referred to a deleted row or a row marked for deletion.
This error does not happen all the time, just for record sets returned with certain contact_id’s. Haven’t been able to pinpoint the difference in the ones that work and the ones that don’t.
As you can see the error happens on rs.movenext.
I have made sure that the table has a primary key (client_notes_id).
Thank you for your help!
EDIT
Here is the code for 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
Here is the update script. This is on a separate page that I post to (kinda AJAX style):
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
openSQL method:
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
Ok I was able to solve this.
I am running the query against a view which joins 2 tables.
The problem was that sometimes a note was submitted without the user id so the join from one table to the other didn’t work cause user id was null. I modified my query to the following:
Now the error doesn’t come back, it just excludes the notes that aren’t assigned to someone. So now on to fixing why the note wasn’t assigned to someone.
Thanks!