ADODB.Recordset error '800a0e78' Operation is not allowed when the object is closed

两盒软妹~` 提交于 2019-12-24 10:57:15

问题


Set RsItem = Conn.Execute("EXEC E_UpdateDevBehaviourSmalls @ClientID=" & Session("ClientID") & " ,@UserID=" & Session("EUserID")& " ,@cCompID=" & cCompetenceid & " ,@reason=" &reason &  " ,@comptype=" & comptype &",@GID=" & GID & " ,@Behaviour='" & MakeSendable(Behaviour) & "' ,@Deadline='" & deadlinedatetime & "' ,@DevBehaviour='" & MakeSendable(DevBehaviour) & "' ,@Why='" & MakeSendable(Why) & "' ,@ExtraNote='" & MakeSendable(ExtraNote) & "'")                                      
if GID = 0 then
    if not RsItem.eof then
        GID = RsItem.fields(0).value
        if reason = 0 then
            'add dummy devbehaviour detail
            Set RsItem =Conn.Execute("EXEC E_UpdateDevBehaviourDetail @ClientID=" & Session("ClientID") & " ,@UserID=" & Session("EUserID") & " ,@GID=" & GID & " ,@DID=0 ,@TextField1='dummy' ,@educ= 0 ,@TextField2='dummy' ,@TextField3='dummy' ,@TextField4='dummy'")
        end if
    end if
end if

When I try to execute the code above (full code below) I got the following error: (It gets stuck at the following part: if not RsItem.fields(0).value)

ADODB.Recordset error '800a0e78'

Operation is not allowed when the object is closed.

Can anyone help me with this error?

<%
    Dim DID
    Dim GID
    Dim cCompetenceid
    Dim Behaviour
    Dim Deadline
    Dim DevBehaviour
    Dim Why
    Dim ExtraNote

    MakeConn
        Session("OnlinePageID") = 106
        InsertLogItem "S:12"

        If Session("EUserType")=1 Then
            If UCase(Request("Action"))="SAVEDETAIL" Then
                If not Request("DID")="" Then
                    DID = Request("DID")
                Else
                    DID = 0
                End If

Conn.Execute("EXEC E_UpdateDevBehaviourDetail @ClientID=" & Session("ClientID") & " ,@UserID=" & Session("EUserID") & " ,@GID=" & Request("GID") & " ,@DID=" & DID & " ,@TextField1='" & MakeSendable(Request("TextField1")) & "' ,@TextField2='" & MakeSendable(Request("TextField2")) & "' ,@TextField3='" & MakeSendable(Request("TextField3")) & "' ,@TextField4='" & MakeSendable(Request("TextField4")) & "'")
                Conn.Execute("EXEC E_SignIDP @ClientID=" & Session("ClientID") & " ,@UserID=" & Session("EUserID") & " ,@SignStatus=0")
            End If
        End If
'response.write Session("EUserType") & "<br>"
        If Session("EUserType")=1 Then
            Select Case UCase(Request("Action"))
                Case "EDIT"
                    If not Request("GID")="" Then
                        'response.write "EXEC E_GetDevBehavior @ClientID=" & Session("ClientID") & " ,@UserID=" & Session("EUserID") & " ,@GID=" & Request("GID") & "<br>"

                        Set RsItem = Conn.Execute("EXEC E_GetDevBehavior @ClientID=" & Session("ClientID") & " ,@UserID=" & Session("EUserID") & " ,@GID=" & Request("GID"))
                        If not RsItem.EOF Then
                            Behaviour = Replace (RsItem("Behaviour"),"''","'")
                            Deadline = RsItem("Deadline")
                            DevBehaviour = Replace (RsItem("DevBehaviour"),"''","'")
                            Why = Replace (RsItem("Why"),"''","'")
                            ExtraNote = Replace (RsItem("ExtraNote"),"''","'")
                        Else
                            Response.End
                        End If
                        'RsItem.close
                        'Set RsItem = nothing

                    Else

                    End If
                Case "SAVE"

                    If not Request("GID")="" Then
                    Set RsItem = Conn.Execute("EXEC E_GetDevBehavior @ClientID=" & Session("ClientID") & " ,@UserID=" & Session("EUserID") & " ,@GID=" & Request("GID"))
                        If not RsItem.EOF Then
                            Behaviour = Replace (RsItem("Behaviour"),"''","'")
                            Deadline = RsItem("Deadline")
                            DevBehaviour = Replace (RsItem("DevBehaviour"),"''","'")
                            Why = Replace (RsItem("Why"),"''","'")
                            ExtraNote = Replace (RsItem("ExtraNote"),"''","'")
                        Else
                            Response.End
                        End If
                        'RsItem.close
                        'Set RsItem = nothing

                    end if
                    dag = Day(Now())
                    maand = Month(Now())
                    jaar = Year(Now())

                    uur = Hour(Time)
                    minuten = Minute(Time)
                    seconden = Second(Time)


                    if len(dag)< 2 then dag ="0" & dag
                    if len(maand) < 2 then maand ="0" & maand

                    if len(uur) < 2 then uur ="0" & uur
                    if len(minuten) < 2 then minuten ="0" & minuten 
                    if len(seconden) < 2 then seconden ="0" & seconden


                    datum= jaar & "-" & maand & "-" & dag
                    tijd = uur & ":" & minuten& ":" & seconden
                    datumtijd = datum & " " & tijd
                    Conn.Execute("EXEC E_UpdatePOPStartDate @ClientID=" & Session("ClientID") & " ,@UserID=" & Session("EUserID"))
                    Conn.Execute("EXEC E_UpdateStartDate @ClientID=" & Session("ClientID") & " ,@UserID=" & Session("EUserID") & " ,@StartDate='" & datumtijd & "'")
                    If not Request("GID")="" Then
                        GID = Request("GID")
                        newcomp = false
                    Else
                        GID = 0
                        Deadline = CDate(FormatDate("31/12/"&year(now)))
                        newcomp = true
                    End If
                    'response.write Request("cCompetenceid") &"<br>"
                    if not Request("cCompetenceid") = "" then
                        cCompetenceid = Request("cCompetenceid")
                    else
                        cCompetenceid = 0
                    end if
                    if not Request("reason") = "" then
                        reason = Request("reason")
                    else
                        reason = 0
                    end if
                    if not Request("comptype") = "" then
                        comptype = Request("comptype")
                    else
                        comptype = 1
                    end if
                    Select Case (Request("COMPID"))
                    Case 1460
                        Behaviour = Request("Behaviour")
                    Case 1461
                        Deadline = Request("DeadlineDay") & "-" & Request("DeadlineMonth") & "-" & Request("DeadlineYear")
                        Deadline = CDate(FormatDate(Deadline))
                    Case 1462
                        DevBehaviour = Request("DevBehaviour")
                    Case 1463
                        Why = Request("Why")

                    Case 1464
                        ExtraNote = Request("ExtraNote")
                    End Select
                    deadlinedate = CDate(Deadline)
                    deadlineyear = year(deadlinedate)
                    deadlinemonth = month(deadlinedate)
                    deadlineday = day(deadlinedate)

                    deadlinedatetime =  deadlineyear & "-" & deadlinemonth & "-" & deadlineday & " 00:00:00"
                    'response.write "EXEC E_UpdateDevBehaviourSmalls @ClientID=" & Session("ClientID") & " ,@UserID=" & Session("EUserID")& " ,@cCompID=" & cCompetenceid & " ,@reason=" &reason &  " ,@comptype=" & comptype &",@GID=" & GID & " ,@Behaviour='" & MakeSendable(Behaviour) & "' ,@Deadline='" & deadlinedatetime & "' ,@DevBehaviour='" & MakeSendable(DevBehaviour) & "' ,@Why='" & MakeSendable(Why) & "' ,@ExtraNote='" & MakeSendable(ExtraNote) & "'"
                    'response.end
                            Set RsItem = Conn.Execute("EXEC E_UpdateDevBehaviourSmalls @ClientID=" & Session("ClientID") & " ,@UserID=" & Session("EUserID")& " ,@cCompID=" & cCompetenceid & " ,@reason=" &reason &  " ,@comptype=" & comptype &",@GID=" & GID & " ,@Behaviour='" & MakeSendable(Behaviour) & "' ,@Deadline='" & deadlinedatetime & "' ,@DevBehaviour='" & MakeSendable(DevBehaviour) & "' ,@Why='" & MakeSendable(Why) & "' ,@ExtraNote='" & MakeSendable(ExtraNote) & "'")                                      
                    if GID = 0 then
                        if not RsItem.eof then
                            GID = RsItem.fields(0).value
                            if reason = 0 then
                            ' add dummy devbehaviour detail
                            Set RsItem =Conn.Execute("EXEC E_UpdateDevBehaviourDetail @ClientID=" & Session("ClientID") & " ,@UserID=" & Session("EUserID") & " ,@GID=" & GID & " ,@DID=0 ,@TextField1='dummy' ,@educ= 0 ,@TextField2='dummy' ,@TextField3='dummy' ,@TextField4='dummy'")
                            end if
                        end if
                    end if
                    'RsItem.close
                    'Set RsItem = nothing

                    Conn.Execute("EXEC E_SignIDP @ClientID=" & Session("ClientID") & " ,@UserID=" & Session("EUserID") & " ,@SignStatus=0")
                    if newcomp = true then
                        tempstr = "../popoverview.asp"
                        ClientScript("parent.location.href  = '../bottomframe.asp?GID=" & GID & "&" & SetID &"&ViewID=4'" )
                    else
                        response.write " in"
                        tempstr = "compoverview.asp?Action=Edit&GID="&GID
                        response.redirect tempstr
                        ' ClientScript("location.href  =" & tempstr)
                    end if
            End Select
        End If
conn.close
set conn= nothing
%>

Stored procedure:

USE [Q]
GO
/****** Object:  StoredProcedure [dbo].[E_UpdateDevBehaviourSmalls]    Script Date:       17/10/2013 15:05:53 ******/
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER PROCEDURE [dbo].[E_UpdateDevBehaviourSmalls]
(@ClientID int,
 @UserID int,
 @cCompID int,
@reason int,
@comptype int,
 @GID int,
 @Behaviour varchar(250),
 @Deadline datetime,
 @DevBehaviour text,
 @Why text,
 @ExtraNote text)
AS

If (@GID = 0)
BEGIN
    INSERT INTO     DevBehaviour(ClientID,UserID,Behaviour,Deadline,DevBehaviour,Why,ExtraNote,cCompId,reason,comptype)
        VALUES(@ClientID,@UserID,@Behaviour,@Deadline,@DevBehaviour,@Why,@ExtraNote, @cCompID,@reason,@comptype) 
    SELECT @@identity
END
Else
BEGIN
    UPDATE DevBehaviour
    SET Behaviour=@Behaviour, Deadline=@Deadline, DevBehaviour=@DevBehaviour, Why=@Why, ExtraNote=@ExtraNote, cCompId = @cCompID, reason = @reason, comptype = @comptype 
    WHERE (ClientID = @ClientID) AND (UserID = @UserID) AND (GID = @GID)
END

回答1:


I was able to reproduce your problem. Please try the stored proc below (using nocount)

USE [Q]
GO
/****** Object:  StoredProcedure [dbo].[E_UpdateDevBehaviourSmalls]    Script Date:       17/10/2013 15:05:53 ******/
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER PROCEDURE [dbo].[E_UpdateDevBehaviourSmalls]
(@ClientID int,
 @UserID int,
 @cCompID int,
@reason int,
@comptype int,
 @GID int,
 @Behaviour varchar(250),
 @Deadline datetime,
 @DevBehaviour text,
 @Why text,
 @ExtraNote text)
AS

set nocount on
If (@GID = 0)
BEGIN
    INSERT INTO     DevBehaviour(ClientID,UserID,Behaviour,Deadline,DevBehaviour,Why,ExtraNote,cCompId,reason,comptype)
        VALUES(@ClientID,@UserID,@Behaviour,@Deadline,@DevBehaviour,@Why,@ExtraNote, @cCompID,@reason,@comptype) 
    SELECT @@identity
END
Else
BEGIN
    UPDATE DevBehaviour
    SET Behaviour=@Behaviour, Deadline=@Deadline, DevBehaviour=@DevBehaviour, Why=@Why, ExtraNote=@ExtraNote, cCompId = @cCompID, reason = @reason, comptype = @comptype 
    WHERE (ClientID = @ClientID) AND (UserID = @UserID) AND (GID = @GID)
END
set nocount off


来源:https://stackoverflow.com/questions/19429061/adodb-recordset-error-800a0e78-operation-is-not-allowed-when-the-object-is-clo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!