ADODB.Recordset错误'800a0e78'对象关闭时不允许操作

时间:2013-10-17 14:10:43

标签: asp-classic recordset

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

当我尝试执行上面的代码时(下面的完整代码),我收到以下错误: (它停留在以下部分:if not RsItem.fields(0).value

  

ADODB.Recordset错误'800a0e78'

     

关闭对象时不允许操作。

任何人都可以帮我解决这个错误吗?

<%
    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
%>

存储过程:

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 个答案:

答案 0 :(得分:1)

我能够重现你的问题。请尝试下面的存储过程(使用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