Operation Is Not Allowed When The Object Is Closed!

Discussion in 'ASP General' started by Arpan, Sep 4, 2005.

  1. Arpan

    Arpan Guest

    An ASP application updates a SQL Server database table after a Form is
    submitted after which the user is directed to another page that should
    display the updated records. If the code is

    ----------------------------------------
    'records get updated here
    Response.Redirect("Records.asp")

    objRS.Close
    Set objRS=Nothing
    objConn.Close
    Set objConn=Nothing
    ----------------------------------------

    then the user is correctly shown the updated records after redirection.
    If the code is

    ----------------------------------------
    'records get updated here
    Server.Transfer("Records.asp")

    objRS.Close
    Set objRS=Nothing
    objConn.Close
    Set objConn=Nothing
    ----------------------------------------

    then the updated records aren't reflected. The updated records can be
    seen only after refreshing the page. If the code is

    ----------------------------------------
    'records get updated here
    Server.Execute("Records.asp")

    objRS.Close
    Set objRS=Nothing
    objConn.Close
    Set objConn=Nothing
    ----------------------------------------

    then the "Operation is not allowed when the object is closed" error
    gets generated though the records in the table get updated.

    If any of the 3 Response.Redirect or Server.Execute or Server.Transfer
    lines are placed after closing the recordset object & the connection
    object, again the above error gets generated though the records in the
    database get updated successfully in each of the 3 cases. What causes
    the above mentioned error & the difference in the output displayed?

    Thanks,

    Arpan
    Arpan, Sep 4, 2005
    #1
    1. Advertising

  2. Arpan

    Jeff Cochran Guest

    On 3 Sep 2005 17:46:33 -0700, "Arpan" <> wrote:

    >An ASP application updates a SQL Server database table after a Form is
    >submitted after which the user is directed to another page that should
    >display the updated records. If the code is
    >
    >----------------------------------------
    >'records get updated here
    >Response.Redirect("Records.asp")
    >
    >objRS.Close
    >Set objRS=Nothing
    >objConn.Close
    >Set objConn=Nothing
    >----------------------------------------
    >
    >then the user is correctly shown the updated records after redirection.
    >If the code is
    >
    >----------------------------------------
    >'records get updated here
    >Server.Transfer("Records.asp")
    >
    >objRS.Close
    >Set objRS=Nothing
    >objConn.Close
    >Set objConn=Nothing
    >----------------------------------------
    >
    >then the updated records aren't reflected. The updated records can be
    >seen only after refreshing the page. If the code is
    >
    >----------------------------------------
    >'records get updated here
    >Server.Execute("Records.asp")
    >
    >objRS.Close
    >Set objRS=Nothing
    >objConn.Close
    >Set objConn=Nothing
    >----------------------------------------
    >
    >then the "Operation is not allowed when the object is closed" error
    >gets generated though the records in the table get updated.
    >
    >If any of the 3 Response.Redirect or Server.Execute or Server.Transfer
    >lines are placed after closing the recordset object & the connection
    >object, again the above error gets generated though the records in the
    >database get updated successfully in each of the 3 cases. What causes
    >the above mentioned error & the difference in the output displayed?


    The cause is the fact that you don't understand what happens in a
    Server.Redirect, Server.Transfer or Server.Execute. Google for
    tutorials on those. Don't close a recordset on a page that didn't
    open them (poor programming) .

    Jeff
    Jeff Cochran, Sep 4, 2005
    #2
    1. Advertising

  3. Arpan

    Arpan Guest

    Thanks Jeff for your suggestion.

    Regards,

    Arpan
    Arpan, Sep 5, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    1
    Views:
    2,109
    Kevin Spencer
    Aug 10, 2005
  2. Matthew Louden
    Replies:
    6
    Views:
    245
    Ken Schaefer
    Sep 28, 2003
  3. cliverama
    Replies:
    1
    Views:
    131
    Aaron Bertrand [MVP]
    Nov 5, 2003
  4. Guest
    Replies:
    1
    Views:
    230
    Ray Costanzo [MVP]
    Dec 20, 2004
  5. TC
    Replies:
    1
    Views:
    140
    madhouse
    Jan 12, 2005
Loading...

Share This Page