Operation is not allowed when the object is closed 
Author Message
 Operation is not allowed when the object is closed

I am working with a com object that returns recordsets. I am accesssing this
from an ASP page. Half the time, the recordset will be empty. However, when
I try to check to see if the recordset is empty I get the 'Operation is not
allowed when the object is closed' error message. Can anyone tell me where
I'm going wrong?

The code in the com object is this :

Public Function GetUserSuppressions(ByVal lRecID As Long) As ADODB.Recordset

    Dim sSQL As String
    Dim rsSupps As New ADODB.Recordset

    sSQL = "SELECT * FROM SUPPRESSION WHERE SUP_RECIPIENT_ID = '" & lRecID &
"'"

    Set rsSupps = GetRecordset(sSQL)

    If rsSupps.EOF And rsSupps.BOF Then
        Set GetUserSuppressions = Nothing
        Exit Function
    End If

    Set GetUserSuppressions = rsSupps

    Set rsSupps = Nothing

End Function

In the ASP page, the first line here causes an error :

if not oRs.EOF and oRs.BOF then
  oRs.movefirst
end if

This is skipped (ie recordset is not nothing) :

 if oRs is nothing then
  Response.Write "oRs is empty."
  Response.End
 end if

Cheers.



Tue, 09 Mar 2004 17:46:43 GMT  
 Operation is not allowed when the object is closed
Check the state;

if objRS.State <> 1 then
    ' rs is not open
end if


Quote:
> I am working with a com object that returns recordsets. I am accesssing
this
> from an ASP page. Half the time, the recordset will be empty. However,
when
> I try to check to see if the recordset is empty I get the 'Operation is
not
> allowed when the object is closed' error message. Can anyone tell me where
> I'm going wrong?

> The code in the com object is this :

> Public Function GetUserSuppressions(ByVal lRecID As Long) As
ADODB.Recordset

>     Dim sSQL As String
>     Dim rsSupps As New ADODB.Recordset

>     sSQL = "SELECT * FROM SUPPRESSION WHERE SUP_RECIPIENT_ID = '" & lRecID
&
> "'"

>     Set rsSupps = GetRecordset(sSQL)

>     If rsSupps.EOF And rsSupps.BOF Then
>         Set GetUserSuppressions = Nothing
>         Exit Function
>     End If

>     Set GetUserSuppressions = rsSupps

>     Set rsSupps = Nothing

> End Function

> In the ASP page, the first line here causes an error :

> if not oRs.EOF and oRs.BOF then
>   oRs.movefirst
> end if

> This is skipped (ie recordset is not nothing) :

>  if oRs is nothing then
>   Response.Write "oRs is empty."
>   Response.End
>  end if

> Cheers.



Tue, 09 Mar 2004 18:23:21 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Operation is not allowed when the object is closed

2. Operation is not allowed when the object is closed and CommanTimeout,

3. Operation is not allowed when the object is closed

4. operation is not allowed when the object is closed

5. Operation is not allowed when the object is closed

6. Stored Proc problems - Operation not allowed when the object is closed

7. Operation is not allowed when the object is closed - error

8. operation not allowed when object is closed

9. '3709': Operation is not allowed on an object referencing a closed or invalid connection

10. I am trying to update a record, i am not using data control

11. I am trying to update a record, i am not using data control

12. I am learning VB.NET and am wondering....

 

 
Powered by phpBB® Forum Software