ADODB.Field错误' 80020009'

时间:2013-04-03 20:01:58

标签: asp-classic

最近我们收到了这个错误: ADODB.Field错误'80020009'

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

/PHET/mscripts/TestScoring.asp, line 52 

此特定文件用于其他10个测试,并且不会出错。我检查了数据库,一切看起来都不错。这是抛出错误的实际页面......

<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="DoSecure.asp" -->
<!--#include virtual="/lib/dbConnModules.asp" -->
<%
Dim rsAnswer__MMColParam
rsAnswer__MMColParam = Session("ModuleID")
Set rsAnswer = Server.CreateObject("ADODB.Recordset")
rsStrAnswer = "SELECT * FROM TestAnswers WHERE TestName = '" & Request.Form("testName") & "' and ApplicationID = '" & Session("ApplicationID") & "' and moduleID = '" + Replace(rsAnswer__MMColParam, "'", "''") + "'"
rsAnswer.open rsStrAnswer, dbConnModules
answerArray = array(rsAnswer("AnswerQ1"), rsAnswer("AnswerQ2"), rsAnswer("AnswerQ3"), rsAnswer("AnswerQ4"), rsAnswer("AnswerQ5"), rsAnswer("AnswerQ6"), rsAnswer("AnswerQ7"), rsAnswer("AnswerQ8"), rsAnswer("AnswerQ9"), rsAnswer("AnswerQ10"), rsAnswer("AnswerQ11"), rsAnswer("AnswerQ12"), rsAnswer("AnswerQ13"), rsAnswer("AnswerQ14"), rsAnswer("AnswerQ15"), rsAnswer("AnswerQ16"), rsAnswer("AnswerQ17"), rsAnswer("AnswerQ18"), rsAnswer("AnswerQ19"), rsAnswer("AnswerQ20"))
testArray = array(Request.Form("Q1"), Request.Form("Q2"), Request.Form("Q3"), Request.Form("Q4"), Request.Form("Q5"), Request.Form("Q6"), Request.Form("Q7"), Request.Form("Q8"), Request.Form("Q9"), Request.Form("Q10"), Request.Form("Q11"), Request.Form("Q12"), Request.Form("Q13"), Request.Form("Q14"), Request.Form("Q15"), Request.Form("Q16"), Request.Form("Q17"), Request.Form("Q18"), Request.Form("Q19"), Request.Form("Q20"))
if not rsAnswer.EOF then
    myCorrect = 0
    For i=0 To (rsAnswer("NumOfQs") - 1)
        'Response.Write(i+1 & Request.Form("q" & i+1) & "<br />")
        If isNull(answerArray(i)) then answerArray(i) = "" End If
        If answerArray(i) = testArray(i) Then
            myCorrect = myCorrect + 1
        End if
    Next
    'Response.Write(myCorrect)
end if  
'Response.Write(myCorrect)
%>
<%
strTestRecord = "insert into TestRecords (ApplicationID, ModuleID, TestName, UserEmail, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, Q10, Q11, Q12, Q13, Q14, Q15, Q16, Q17, Q18, Q19, Q20, Debugger, numberCorrect) values ('" &_ 
        Session("ApplicationID") & "', '"&_
        Session("ModuleID") & "', '"&_
        Replace(Request.Form("testName"), "'", "''") & "', '"&_
        Session("UserEmailAddr") & "', '"&_
        Replace(Request.Form("Q1"), "'", "''") & "', '" &_
        Replace(Request.Form("Q2"), "'", "''") & "', '" &_
        Replace(Request.Form("Q3"), "'", "''") & "', '" &_
        Replace(Request.Form("Q4"), "'", "''") & "', '" &_
        Replace(Request.Form("Q5"), "'", "''") & "', '" &_
        Replace(Request.Form("Q6"), "'", "''") & "', '" &_
        Replace(Request.Form("Q7"), "'", "''") & "', '" &_
        Replace(Request.Form("Q8"), "'", "''") & "', '" &_
        Replace(Request.Form("Q9"), "'", "''") & "', '" &_
        Replace(Request.Form("Q10"), "'", "''") & "', '" &_
        Replace(Request.Form("Q11"), "'", "''") & "', '" &_
        Replace(Request.Form("Q12"), "'", "''") & "', '" &_
        Replace(Request.Form("Q13"), "'", "''") & "', '" &_
        Replace(Request.Form("Q14"), "'", "''") & "', '" &_
        Replace(Request.Form("Q15"), "'", "''") & "', '" &_
        Replace(Request.Form("Q16"), "'", "''") & "', '" &_
        Replace(Request.Form("Q17"), "'", "''") & "', '" &_
        Replace(Request.Form("Q18"), "'", "''") & "', '" &_
        Replace(Request.Form("Q19"), "'", "''") & "', '" &_
        Replace(Request.Form("Q20"), "'", "''") & "', '" &_
        Request.Form("Debugger") & "', " & myCorrect & ")"      
Session("NumOfQs") = rsAnswer("NumOfQs")
Session("NumToPass") = rsAnswer("NumToPass")

Session("YourScore") = myCorrect

if myCorrect > Session("NumToPass") then pf = "pass" else pf = "fail" end if ' PASS OR FAIL
strTestRecordComplete = "insert into CheckRequirements (ApplicationID, UserEmail, ModuleID, RequirementName, PassOrFail, OperationalIPAddr) values ('" & Session("ApplicationID") & "', '" & Session("UserEmailAddr") & "', '" & Session("ModuleID") & "', '"& Request.Form("testName") & "', '" & pf & "', '" & Request.ServerVariables("REMOTE_ADDR") & "')"
dbConnModules.Execute(strTestRecord)
dbConnModules.Execute(strTestRecordComplete)
if Request.Form("TestName") = "pretest" Then
    Response.Redirect("../" & Session("ModuleDir") & "/TestResults.asp?fr=pre&desturl="& Request.Form("desturl"))
elseif Request.Form("TestName") = "posttest" Then
    Session("rsYourAnswers") = testArray
    Response.Redirect("../" & Session("ModuleDir") & "/TestResults.asp?fr=post&desturl="& Request.Form("desturl"))
End If
%>
<%
rsAnswer.Close()
Set rsAnswer = Nothing
%>
<!--#include virtual="/lib/dbConnModulesClose.asp" -->

有什么想法吗?感谢。

1 个答案:

答案 0 :(得分:0)

您可以访问两个地方的记录集,而不检查它是否包含任何记录。只需将访问记录集的代码移动到您已有的条件:

rsAnswer.open rsStrAnswer, dbConnModules
testArray = array(Request.Form("Q1"), Request.Form("Q2"), Request.Form("Q3"), Request.Form("Q4"), Request.Form("Q5"), Request.Form("Q6"), Request.Form("Q7"), Request.Form("Q8"), Request.Form("Q9"), Request.Form("Q10"), Request.Form("Q11"), Request.Form("Q12"), Request.Form("Q13"), Request.Form("Q14"), Request.Form("Q15"), Request.Form("Q16"), Request.Form("Q17"), Request.Form("Q18"), Request.Form("Q19"), Request.Form("Q20"))
if not rsAnswer.EOF then
    answerArray = array(rsAnswer("AnswerQ1"), rsAnswer("AnswerQ2"), rsAnswer("AnswerQ3"), rsAnswer("AnswerQ4"), rsAnswer("AnswerQ5"), rsAnswer("AnswerQ6"), rsAnswer("AnswerQ7"), rsAnswer("AnswerQ8"), rsAnswer("AnswerQ9"), rsAnswer("AnswerQ10"), rsAnswer("AnswerQ11"), rsAnswer("AnswerQ12"), rsAnswer("AnswerQ13"), rsAnswer("AnswerQ14"), rsAnswer("AnswerQ15"), rsAnswer("AnswerQ16"), rsAnswer("AnswerQ17"), rsAnswer("AnswerQ18"), rsAnswer("AnswerQ19"), rsAnswer("AnswerQ20"))
    myCorrect = 0
    For i=0 To (rsAnswer("NumOfQs") - 1)
        'Response.Write(i+1 & Request.Form("q" & i+1) & "<br />")
        If isNull(answerArray(i)) then answerArray(i) = "" End If
        If answerArray(i) = testArray(i) Then
            myCorrect = myCorrect + 1
        End if
    Next
    'Response.Write(myCorrect)
    Session("NumOfQs") = rsAnswer("NumOfQs")
    Session("NumToPass") = rsAnswer("NumToPass")
Else  
    Session("NumOfQs") = 0
    Session("NumToPass") = 0
End If

请记住从原始代码的末尾删除这两行:

Session("NumOfQs") = rsAnswer("NumOfQs")
Session("NumToPass") = rsAnswer("NumToPass")

因为它现在被添加到“主要”区块。