Quantcast
Channel: VBForums - ASP, VB Script
Viewing all articles
Browse latest Browse all 686

ADODB.Recordset Closed Error When Executing ADODN.Connection Execute Method

$
0
0
I have a Classic ASP webpage that is updating client information via Stored Procedures in a SQL Server 2008 R2 database. I am executing the SPs through the ADODB.Connection object's EXECUTE method. These SPs are straight UPDATE/INSERT SPs that do not return a resultset. I am getting the following error information from an error throw when I execute one of the SPS: Source: ADODB.Recordset, Number: 3704, Description: Cannot perform operation on closed object. I am not using any ADODB.Recordsets at this point.

Here is the client code calling the SP:

Code:

if not IsEmpty ( ClientData ( CLIENT_TYPE_LIST ) ) THEN
                for each ClientType in ClientData ( CLIENT_TYPE_LIST )
                        cn.Execute "InsertClientType " & _
                                                        FormatNumberForSQL ( ClientData(ClientID) ) & "," & _
                                                        FormatTextStringForSQL ( ClientType )
                        if err.number <> 0 THEN
                                Response.Write "InsertClientType Error"
                                cn.RollbackTrans
                               
                                'Log the exception
                                LogError cn,1010,"ClientSession.asp[UpdateClientInDB()]", _
                                                        "Error inserting client type info (" & ClientData(ClientID) & " - " & ClientData(ClientName) & ")"
                               
                                cn.close
                                UpdateClientInDB = -1
                                SetStatus "ERROR","ERR1010: Error updating client (" & ClientData(ClientID) & " - " & ClientData(ClientName) & " - " & err.source & " - " & err.number & " - " & err.description & ")"
                                exit Function
                        END IF
                NEXT

Here is the SP code:

Code:

ALTER PROCEDURE [dbo].[InsertClientType]
(
        @ClientID    INT,
        @ClientType  VARCHAR(50)
)
AS

SET NOCOUNT ON

BEGIN
    UPDATE ClientTypes
          SET ClientType = @ClientType
        WHERE ClientID = ClientID;
       
        IF @@ROWCOUNT = 0
        BEGIN
                INSERT INTO ClientTypes (ClientID, ClientType)
                VALUES (@ClientID, @ClientType);
        END
       
        RETURN
END

I am stumped at this point. If I comment out this SP, all of the other SPs which use the same conventions for executing the other SPs run fine. Any help or guidance is much appreciated.

Viewing all articles
Browse latest Browse all 686

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>