Error:Operation is not allowed when the object is closed.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dev4kumar
    New Member
    • Nov 2011
    • 1

    Error:Operation is not allowed when the object is closed.

    I am working in classic asp with vbscript.
    I am looking for a solution for an error for long time.So i ll post my query.
    In my ASP page , I am populating a record set from SQL SERVER stored procedure.
    As soon as the record set is populating , i am checking whether it is null or not.
    For that , I added


    If (RSDataset.EOF) Then
    Response.Write( "RecordSet in empty")
    Else
    Response.Write( "Record(s) are in the RecordSet")
    End If
    Response.End

    When the stored procedure returning data it display 'Record(s) are in the RecordSet'.
    When the stored procedure not returning data(ie no rows) it display 'RecordSet in empty'


    But for some cases it is displaying the error


    ADODB.Recordset error '800a0e78'

    Operation is not allowed when the object is closed.

    DataCheckPage.a sp, line 35

    By googling I came to no that , adding SET NO COUNT ON is a solution.That I already added.
    And the Connection is not closed at any stage, as I checked that also.

    Can anyone help me out to resolve this ?
    Last edited by jhardman; Nov 4 '11, 01:57 PM. Reason: Moved to the answers forum. The insights forum is for articles and explanations that you write to help others.
  • jhardman
    Recognized Expert Specialist
    • Jan 2007
    • 3405

    #2
    Which line is giving the error? Is it the rs.eof?

    It sounds like you missed a step filling your recordset. The basic procedure I use is
    1- initialize your connection object
    2- open the connection
    3- initialize the recordset
    4- fill the recordset
    It's been a while since I wrote one from scratch, but it looks something like this:
    Code:
    set objconn = server.createobject("adodb.connection")
    Objconn.open connectionstring
    Set objrs = server.createobject("adodb.recordset")
    Objrs.open objconn querystring
    let me know if this helps.

    Jared

    Comment

    Working...