operation not allowed when object is open

From: hengzhe (hengzhe_at_discussions.microsoft.com)
Date: 12/28/04

  • Next message: Frank Hickman [MVP]: "Re: Easy way to exclude duplicate entries in recordset...."
    Date: Mon, 27 Dec 2004 19:59:01 -0800
    
    

    The following code worked fine when there were only few concidential
    requests(eg.,no more than 10)but an error was encountered while concidential
    requests increased(eg.more than 10 people opened the page concurrently).
    the error reported was:
    Operation not allowed when object is open
    using my error handling mechanism,I can decided that the error occured in
    Rst.Open strSqlRst,Conn,2,2
    but I don't the reason for this.
    Any suggestion would be greatly appreciated, thanks in advance.
         
         Dim aryTableName(2),I,J
         aryTableName(1) = "table1"
         aryTableName(2) ="table2"
         Set Rst = Server.CreateObject("Adodb.RecordSet")
         Conn.BeginTrans
         If blnUseSbjTable Then
              J = 2
         Else
              J = 1
         End If
         For I = 1 To J
              strSqlRst = "Select * From [" & aryTableName(I)
              strSqlRst = strSqlRst & "] Where Student_ID='" & strStuId & "'"
              Rst.Open strSqlRst,Conn,2,2 'adOpenDynamic,adLockPessimistic
                                  'error handling
              fnCheckError "Openning[" & aryTableName(I) & "]"
              If Rst.EOF Then
                   Rst.AddNew
              End If
              Rst("student_ID") = strStuId
              Rst("studentName") = strStuName
              Rst("stdStatus") = "not logged in"
              Rst("C_subject") = strSltSbj
              If strExamSequence <> "" Then
                   Rst("I_ExamSequence") = strExamSequence
              End If
              If strExamSeat <> "" Then
                   Rst("I_ExamSeat") = strExamSeat
              End If
              If strManId <> "" Then
                   Rst("C_ManId") = strManId
              End If
              Rst("L_TestID") = blnTestId
              Rst.Update
              Rst.Close
         Next
         
         set Rst=nothing

         If Err.number<>0 Then
              Conn.RollbackTrans
         Else
              Conn.CommitTrans
         End If
    'definition of function fnCheckError :
    Function fnCheckError(strStatus)
         If Err.number=0 Then
              Exit Function
         Else
              showServerMessage("[" & strStatus & "]error:" & Err.Description)
         End If
    End Function

    'display error message
    Function showServerMessage(strMsg)
         On Error Resume Next
         Dim strScrString
         strMsg = Replace(strMsg,"""","'")
         strMsg = Replace(strMsg,"\","\\")
         strMsg = Replace(strMsg,vbCrLf,"\n")
         strScrString = "<Script language=javascript>" & vbCrLf
         strScrString = strScrString & "var strMsg=" & Chr(34) & strMsg &
    Chr(34) & ";" & vbCrLf
         strScrString = strScrString & "strMsg=strMsg.replace(/\|/g,'\n');" &
    vbCrLf
         strScrString = strScrString & "alert(strMsg);" & vbCrLf
         strScrString = strScrString & "parent.window.close();" & vbCrLf
         strScrString = strScrString & "</script>" & vbCrLf
         Response.Write strScrString
         Response.End
    End Function
      I used ACCESS as a backend.


  • Next message: Frank Hickman [MVP]: "Re: Easy way to exclude duplicate entries in recordset...."