Error: Object is closed

Discussion in 'ASP General' started by Eugene Anthony, Nov 17, 2005.

  1. ASP code to delete a record:

    openDB()

    Set rs = Server.CreateObject("ADODB.Recordset")
    objConn.usp_deleteOptions OptionID,rs

    closeRS()
    closeDB()



    MS SQL Stored Procedure:


    create procedure usp_deleteOptions
    @OptionID int
    AS SET NOCOUNT ON

    DELETE FROM Options WHERE OptionID=@OptionID

    Return
    GO



    Problem:

    When I try to delete a record I get this error:

    Error Type:
    ADODB.Recordset (0x800A0E78)
    Operation is not allowed when the object is closed.


    How do I solve the problem.


    Your help is kindly appreciated.


    Eugene Anthony

    *** Sent via Developersdex http://www.developersdex.com ***
     
    Eugene Anthony, Nov 17, 2005
    #1
    1. Advertising

  2. Eugene Anthony wrote:
    > ASP code to delete a record:
    >
    > openDB()
    >
    > Set rs = Server.CreateObject("ADODB.Recordset")
    > objConn.usp_deleteOptions OptionID,rs
    >
    > closeRS()
    > closeDB()
    >


    >
    >

    Why are you creating an expensive recordset to run a query/procedure that
    does not return records??
    Change the code to:
    openDB()

    objConn.usp_deleteOptions OptionID

    closeRS()
    closeDB()



    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
     
    Bob Barrows [MVP], Nov 17, 2005
    #2
    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,113
    Kevin Spencer
    Aug 10, 2005
  2. Franck
    Replies:
    0
    Views:
    217
    Franck
    Nov 12, 2003
  3. Matthew Louden
    Replies:
    6
    Views:
    247
    Ken Schaefer
    Sep 28, 2003
  4. TC
    Replies:
    1
    Views:
    141
    madhouse
    Jan 12, 2005
  5. Matt Kruse
    Replies:
    5
    Views:
    309
    Richard Cornford
    Sep 9, 2003
Loading...

Share This Page