Foros del Web » Programando para Internet » ASPX (.net) »

Error: Operation is not allowed when the object is closed

Estas en el tema de Error: Operation is not allowed when the object is closed en el foro de ASPX (.net) en Foros del Web. Saludos a todos. Soy nuevo en el foro, y quisiera saber si alguien me puede ayudar con un problema en un sitio que estoy tratando ...
  #1 (permalink)  
Antiguo 31/03/2010, 13:22
 
Fecha de Ingreso: marzo-2010
Mensajes: 1
Antigüedad: 14 años
Puntos: 0
Error: Operation is not allowed when the object is closed

Saludos a todos. Soy nuevo en el foro, y quisiera saber si alguien me puede ayudar con un problema en un sitio que estoy tratando de modificar.

El error se produce en una página para administrar contenidos traídos desde una base de datos(Noticias). Al tratar de guardar una Noticia, aparece el siguiente error:

Código:
Operation is not allowed when the object is closed. 

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Runtime.InteropServices.COMException: Operation is not allowed when the object is closed.

Source Error: 
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. 

Stack Trace: 

[COMException (0x800a0e78): Operation is not allowed when the object is closed.]
   ADODB.RecordsetClass.get_EOF() +0
   Noticia.gCreaNoticia(Int64 lngIdNoticia, String strTitulo, String strSubTitulo, Int64 lngImgFull, Int64 lngImgBreve, String strContenido, String strBreve, String strUrl, CheckBoxList lstChk, String strTags, Int64 lngFlash, String strFecha, Boolean blnActivar) +1125
   Upload.btnNoticia_Click(Object sender, EventArgs e) +597
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565

Version Information: Microsoft .NET Framework Version:2.0.50727.3053; ASP

El código con el que ingreso las noticias esta dividido en varios archivos. El de la página principal es este:

Código:
       Dim lngUrlFull As Long
        Dim lngUrlBreve As Long
        Dim lngUrlFlash As Long

        lngUrlBreve = 0
        lngUrlFull = 0
        lngUrlFlash = 0
        If Trim(fluImagenFull.FileName) <> "" Then
            Call gArchivo2Byte(fluImagenFull)
            lngUrlFull = gCreaImagen(lngUrlFull, txtAltImagenFull.Text)
        End If

        'strImgBreve = gSubirArchivo(fluImagenBreve, "IMG")
        'lngUrlBreve = gCreaEnlace(strImgBreve, gcintImagen)
        If Trim(fluImagenBreve.FileName) <> "" Then
            Call gArchivo2Byte(fluImagenBreve)
            lngUrlBreve = gCreaImagen(lngUrlBreve, txtAltImagenBreve.Text)
        End If

        If Trim(fluFlash.FileName) <> "" Then
            Call gArchivo2Byte(fluFlash)
            lngUrlFlash = gCreaImagen(lngUrlFlash, txtAltImagenBreve.Text)
        End If

        If gCreaNoticia(glngNoticia, txtTitulo.Text, txtSubTitulo.Text, lngUrlFull, lngUrlBreve, txtNoticia.Text, txtBreve.Text, Trim(txtUrl.Text), chkCategorias, txtTags.Text, lngUrlFlash, txtFecha.Text, chkActivar.Checked) Then
            strMsg = "Noticia guardada con exito"
        Else
            strMsg = "La Noticia no pudo ser Creada"
        End If
        lblNoticia.Text = strMsg
        lblNoticia.ForeColor = Drawing.Color.Red

La función gCreaNoticia(que crea la noticia) es esta:

Código:
Public Function gCreaNoticia(ByVal lngIdNoticia As Long, ByVal strTitulo As String, ByVal strSubTitulo As String, ByVal lngImgFull As Long, ByVal lngImgBreve As Long, ByVal strContenido As String, ByVal strBreve As String, ByVal strUrl As String, ByVal lstChk As CheckBoxList, ByVal strTags As String, ByVal lngFlash As Long, ByVal strFecha As String, ByVal blnActivar As Boolean) As Boolean
        Dim strSql As String
        Dim adoRs1 As New ADODB.Recordset
        Dim blnOk As Boolean
        Dim blnEstado As Boolean
        Dim tipo As Long
        Dim lNoticiasCategoria As Long
        blnEstado = True
        blnOk = False
        If strFecha = "" Then
            strFecha = CStr(fFecha2Num(gObtieneFechaActual, gObtieneHoraActual))
        End If
        lngIdNoticia = gTraeNoticia()

        If blnActivar Then
            strSql = "INSERT INTO Noticias (NS_Id, NS_Titulo, NS_Subtitulo, NS_Breve, NS_Contenido, NS_Imagen, NS_ImgBreve, NS_Flash, NS_Tags, NS_Url, NS_DigFecha, NS_Estado) VALUES (" & lngIdNoticia & ", '" & strTitulo & "', '" & strSubTitulo & "', '" & Mid(strBreve, 1, 400) & "', '" & strContenido & "', " & lngImgFull & ", " & lngImgBreve & ", " & lngFlash & ", '" & strTags & "', '" & strUrl & "', " & Val(strFecha) & ", 1)"
        Else
            strSql = "INSERT INTO Noticias (NS_Id, NS_Titulo, NS_Subtitulo, NS_Breve, NS_Contenido, NS_Imagen, NS_ImgBreve, NS_Flash, NS_Tags, NS_Url, NS_DigFecha, NS_Estado) VALUES (" & lngIdNoticia & ", '" & strTitulo & "', '" & strSubTitulo & "', '" & Mid(strBreve, 1, 400) & "', '" & strContenido & "', " & lngImgFull & ", " & lngImgBreve & ", " & lngFlash & ", '" & strTags & "', '" & strUrl & "', " & Val(strFecha) & ", 0)"
        End If

        If dbCreaConsultaModificacion(strSql, adoRs1) Then
            If Not adoRs1.EOF Then
                glngEnlace = gTraeEnlace()
                For lngItem = 0 To lstChk.Items.Count - 1
                    If lstChk.Items(lngItem).Selected Then
                        tipo = lstChk.Items(lngItem).Value
                    End If
                Next lngItem
                If gCreaEnlace(glngEnlace, strUrl, tipo) Then
                    glngNoticiaEnlace = gTraeNoticiaEnlace()
                    If gCreaNoticiaEnlace(glngNoticiaEnlace, lngIdNoticia, glngEnlace, tipo, strFecha) Then
                        If gCreaNoticiaCategoria(lngIdNoticia, tipo) Then
                            lNoticiasCategoria = gTraeNoticiaCategoria(lngIdNoticia, lstChk)
                        End If
                    End If
                End If
            End If
            blnOk = True
        End If
        adoRs1 = Nothing
        gCreaNoticia = blnOk
    End Function
Las llamada final a la base de datos, la hago con la función dbCreaConsultaModificacion:

Código:
 
Public Function dbCreaConsultaModificacion(ByVal strSql As String, ByVal adoRs As ADODB.Recordset) As Boolean
        Try
            If gblnBaseAbierta = False Then
                Call dbInit()
            End If
            adoRs.Open(strSql, gCn, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)
            dbCreaConsultaModificacion = True
        Catch ex As Exception
            dbCreaConsultaModificacion = False
        End Try
    End Function
Le he dado varias vueltas, y no he dado con la solución a esto.

Espero sus comentarios

Saludos, y desde ya gracias.
  #2 (permalink)  
Antiguo 31/03/2010, 17:08
 
Fecha de Ingreso: octubre-2000
Mensajes: 1.692
Antigüedad: 23 años, 5 meses
Puntos: 19
Respuesta: Error: Operation is not allowed when the object is closed

Hola

Primero te comento que ese código es de ASP, y este foro de ASP.NET por lo tanto a lo mejor deberías preguntar en el foro de ASP.

Por otro lado está muy confuso el código, sobre todo porque estás llamando a una función para que te cree un recordSet y luego lo usas dentro de otra función. Lo cual te está haciendo estos problemas.

Yo te recomendaría que si estas usando ASP.NET uses para acceso a datos ADO.NET, porque si bien podes usar recordSet en ASP.NET no es nada recomendable.

Saludos
__________________
PD: Con amor, fe, amor a Dios y amistad podemos hacer un mundo mejor!!!!

Etiquetas: closed, object, aspx
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 19:39.