ADODB.Recordset (0x800A0E78) - Operation is not allowed when the object is closed.

From: Julio (kotroneus_at_hotmail.com)
Date: 02/27/04


Date: Fri, 27 Feb 2004 02:41:07 -0800

Hi, i have an aruitecture in three layers (Com+ component) based in an ASP app, The database ius SQL Server 2000, and all the queries are stored al stored procedures
I have a DB Layer to communicate with the Database, this an example of a function to call a SP with parameters to get a RS.
Public Function GFQueryStoredProcedureParameter_RS(ByVal lsStoredProcedure As String, _
                                                ByRef loParameters() As String) _
                                                As ADODB.Recordset
    
    On Error GoTo ErrorHandler
    
    Dim loConnection As New ADODB.Connection
    Dim loCommand As ADODB.Command
    Dim loRecordset As ADODB.Recordset
    
    Dim lbRet As Boolean
    Dim liContador As Integer
    Dim liErrores As Integer
    Dim loLog As LogManager.Log
    Dim loContext As ObjectContext
    
    Set loContext = GetObjectContext()
   
    If loContext Is Nothing Then
        Set loLog = CreateObject("LogManager.Log")
        Set loConnection = CreateObject("ADODB.Connection")
        Set loCommand = CreateObject("ADODB.Command")
        Set loRecordset = CreateObject("ADODB.Recordset")
    Else
        Set loLog = loContext.CreateInstance("LogManager.Log")
        Set loConnection = loContext.CreateInstance("ADODB.Connection")
        Set loCommand = loContext.CreateInstance("ADODB.Command")
        Set loRecordset = loContext.CreateInstance("ADODB.Recordset")
    End If
    
    loConnection.Open GFGetConnectionString
    
    loCommand.ActiveConnection = loConnection
    loCommand.CommandType = adCmdStoredProc
    loCommand.CommandText = lsStoredProcedure
    loCommand.CommandTimeout = 15
    
    Dim liItem As Integer
    For liItem = 0 To UBound(loParameters)
        ' Creamos los parĂ¡metros para mandarselos al procedimiento almacenado.
        Dim loParameter As New Parameter
        Set loParameter = loCommand.CreateParameter(CStr(loParameters(0, liItem)), adInteger, adParamInput, 4, CInt(loParameters(1, liItem)))
        loCommand.Parameters.Append loParameter
    Next
    
    Set loRecordset = loCommand.Execute
    
    If (loConnection.Errors.Count <> 0) Then
        For liContador = 0 To loConnection.Errors.Count - 1
            'Los errores del 0 al 10 son informativos.
            If (loConnection.Errors.Item(liContador).Number > SQL_INFORMATION) Then
                Call loLog.GFAdd(loConnection.Errors.Item(liContador).Number, loConnection.Errors.Item(liContador).Description, "busGTKI.dll [modBase.bas (Function: GFQueryStoredProcedureParameter)]", ERROR_TYPE)
                liErrores = liErrores + 1
            Else
                Call loLog.GFAdd(loConnection.Errors.Item(liContador).Number, loConnection.Errors.Item(liContador).Description, "busGTKI.dll [modBase.bas (Function: GFQueryStoredProcedureParameter)]", INFORMATION_TYPE)
            End If
        Next
    End If
    
    If (liErrores <> 0) Then
        loLog.GFDump
        If Not loContext Is Nothing Then
            loContext.SetAbort
        End If
    Else
        Set GFQueryStoredProcedureParameter_RS = loRecordset
        If Not loContext Is Nothing Then
            loContext.SetComplete
        End If
    End If
    

    Set loConnection = Nothing
    Set loLog = Nothing
    Set loContext = Nothing
    Set loCommand = Nothing
    Set loParameter = Nothing
    Set loRecordset = Nothing
    
    Exit Function
    
ErrorHandler:
    lbRet = loLog.GFAdd(Err.Number, Err.Description, "busGTKI.dll [modBase.bas (Function: GFQueryStoredProcedureParameter)]", ERROR_TYPE)
    If (lbRet = True) Then
        loLog.GFDump
    End If
    
    If Not loContext Is Nothing Then
        loContext.SetAbort
    End If
    
    Set loConnection = Nothing
    Set loLog = Nothing
    Set loContext = Nothing
    Set loCommand = Nothing
    Set loParameter = Nothing
    Set loRecordset = Nothing
    
End Function

At the second layer i have many functions/functionality, like this:
Public Function GFGetOffersByUser( _
                                ByVal liPersona As Integer, _
                                ByVal liState As Integer, _
                                ByVal lsOrder As String, _
                                ByVal lsLang As String _
                                ) As ADODB.Recordset
    On Error GoTo ErrLabel
        
    Dim oMtsCtx As Object
    Set oMtsCtx = GetObjectContext()
    
    Dim loArrOferta
    loArrOferta = Array(Array("@iPersona", adInteger, adParamInput, 4, liPersona), _
                        Array("@iEstado", adInteger, adParamInput, 4, liState), _
                        Array("@sOrder", adVarChar, adParamInput, 10, lsOrder), _
                        Array("@sLang", adChar, adParamInput, 1, lsLang))
    
    Set GFGetOffersByUser = GFExecSPParam("GetOffersByUser_sp", loArrOferta)
    
    If Not oMtsCtx Is Nothing Then
      oMtsCtx.SetComplete
    End If
    
    Set oMtsCtx = Nothing
    
    Exit Function
    
ErrLabel:
    If Not oMtsCtx Is Nothing Then
      oMtsCtx.SetAbort
    End If
    Err.Raise Err.Number, Err.Source & " -> busGTKI.GFGetOffersByUser", Err.Description
End Function

And at the ASP
Dim loRSOfertas 'As ADODB.Recordset
Set loRSOfertas = Server.CreateObject("adodb.recordset")
Dim loRSFilter 'As ADODB.Recordset.
Set loRSFilter = Server.CreateObject("adodb.recordset")
        
lsTitle = "Todas las Ofertas"
                        
' Recogemos en un recordset todas las ofertas.
Set loSICOE = Server.CreateObject("busGTKI.busRRHH")
                                        
If (lsOrder <> "") Then
        Set loRSFilter = loSICOE.GFGetOffersByUser (CInt(liPersona), CInt(0), CStr(lsOrderBy), CStr(lsLanguage))
Else
        Set loRSFilter = loSICOE.GFGetOffersByUser(CInt(liPersona), CInt(0), "fec", CStr(lsLanguage))
End If
        
Set loSICOE = Nothing

If (loRS_Ofertas.EOF) AND (loRS_Ofertas.BOF) Then
                lbRows = false
Else%><input Type="text" Id="lstOffers" name="lstOffers" /><%
        lbRows = true
        liRows = 0
                                                        
        'Recorremos el Recordset y "pintamos" los resultados.
        Do While Not(loRS_Ofertas.EOF)
                If (liRows Mod 2 = 0) Then
                        lsColor = "#FFFFFF"
                Else
                        lsColor = "#E7E3E7"
                End If%><tbody><tr><td class="texto" align="center" bgcolor="<%=lsColor%>">" title="Ver detalle de la Oferta"><%=loRS_Ofertas("IOFERTA")%></td><td bgcolor="<%=lsColor%>" align="center" class="texto">" title="Ver detalle de la Oferta"><%=loRS_Ofertas("SDPUESTO")%></td></tr></tbody><%liRows = liRows + 1
        loRS_Ofertas.MoveNext
Loop
End If%>

SomeOne have any idea, i am getting crazy

Thanks in advance

(Note: i have test the component with a Win32 app and works fine.)

Julio
(CGE&Y)



Relevant Pages

  • Re: ADODB.Recordset (0x800A0E78) - Operation is not allowed when the object is closed.
    ... Dim loConnection As ADODB.Connection ... Set loConnection = New ADODB.Connection ... > Set loContext = GetObjectContext> ... > Dim oMtsCtx As Object ...
    (microsoft.public.data.ado)
  • Re: Connection-maker macro?
    ... directly to the Connector layer. ... Dim collShapes As Collection ... Dim shps As Visio.Shapes ...
    (microsoft.public.visio.developer)
  • Re: Connection-maker macro?
    ... Dim lyr As Visio.Layer ... Free Visio shapes: ... Visio programming info: ... directly to the Connector layer. ...
    (microsoft.public.visio.developer)
  • Re: VB.net and ASP.Net Typed Datasets
    ... That pretty much means strings and XML. ... your data layer go and get the SQL data and return that to the business ... business layer is not needed at all (which you can't do right now because ... Dim theDataSet As New DataSet ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: VB.net and ASP.Net Typed Datasets
    ... That pretty much means strings and XML. ... layer so the business layer can perform business logic on the data (if there ... Dim theDataSet As New DataSet ...
    (microsoft.public.dotnet.framework.adonet)