error when trying to delete object

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default error when trying to delete object

    i get this error when i am trying to close my object after this operation!
    What can be wrong?
    Regards Mikael

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

    My code

    <%@ Language=VBScript%>
    <!-- #include file ="./connectionStr\conStr.inc" -->
    <%
    if isEmpty(session("medlemsNr")) then
    response.redirect("./somepage.asp")
    end if

    Response.buffer=true
    Response.ExpiresAbsolute = Now()
    Response.AddHeader "Cache-Control", "private"
    session("last_move")=time()
    '--------------------------------------------------------------
    Dim objConn ' ADO Recordset Object
    Dim objRS ' ADO Connection Object
    Dim strSQL
    '--------------------------------------------------------------
    Set objConn = Server.CreateObject("ADODB.Connection")
    objConn.ConnectionString=connectionStr
    objConn.Open
    '--------------------------------------------------------------
    Set objRS = Server.CreateObject("ADODB.Recordset")

    strSQL="delete from rosor where id=" & request.QueryString("id")
    objRS.Open strSQL, objConn

    objRS.Close
    Set objRS = Nothing

    objConn.Close
    Set objConn = Nothing
    str="./rosor.asp?medlemsNr=" & request.QueryString("medlemsNr")

    response.Redirect(str)

    %>


    Mikael Hellström Guest

  2. Similar Questions and Discussions

    1. Can't delete object in Acrobat 7
      We moved to OSX recently and we're now using Acrobat 7. In Acrobat 4 or 5, we used to select the Arrow too and we wre able to delete objects from...
    2. Zaragosa Barbosa : Is there a Fixup to delete an page object?
      Jon, Those fixups only remove objects completely outside the trim area or page area. I'm not sure that's what Zaragosa is looking for (I think...
    3. Is there a Fixup to delete an page object?
      I have a preflight action that finds extremely narrow, misplaced images in PDF files (they're generally things where something was supposed to stop...
    4. Delete stream object
      If I use netStream.close command I stop the stream but I don't delete the object that remain in server with the number ID of client and the status...
    5. Accessing data object on delete command.
      Hi guys. I have a datagrind that is bound to a custom collection of a custom object. When a delete button is pressed in the datagrid, I not...
  3. #2

    Default Re: error when trying to delete object

    Recordsets are for holding records returned from the server. A DELETE query
    does not return any records. Hence your recordset is not open. Hence you
    can't call .Close()

    All you really need is the connection object:

    <%
    Set objConn = Server.CreateObject("ADODB.Connection")
    objConn.Open(connectionStr)

    strSQL="delete from rosor where id=" & request.QueryString("id")

    objConn.Execute(strSQL)
    objConn.Close
    Set objConn = Nothing
    %>

    But you are not filtering Request.QueryString for malicious input - you need
    to do that to prevent SQL Injection attacks. At the very least:

    <%
    intID = Request.QueryString("id")
    If not isNumeric(intID) or Len(intID) = 0 then
    intID = -1
    End If

    strSQL = "delete from rosor where id=" & intID
    %>

    Cheers
    Ken

    "Mikael Hellström" <micke.hellstrom@telia.com> wrote in message
    news:ydRgc.56571$mU6.233598@newsb.telia.net...
    : i get this error when i am trying to close my object after this operation!
    : What can be wrong?
    : Regards Mikael
    :
    : Error Type:
    : ADODB.Recordset (0x800A0E78)
    : Operation is not allowed when the object is closed.
    :
    : My code
    :
    : <%@ Language=VBScript%>
    : <!-- #include file ="./connectionStr\conStr.inc" -->
    : <%
    : if isEmpty(session("medlemsNr")) then
    : response.redirect("./somepage.asp")
    : end if
    :
    : Response.buffer=true
    : Response.ExpiresAbsolute = Now()
    : Response.AddHeader "Cache-Control", "private"
    : session("last_move")=time()
    : '--------------------------------------------------------------
    : Dim objConn ' ADO Recordset Object
    : Dim objRS ' ADO Connection Object
    : Dim strSQL
    : '--------------------------------------------------------------
    : Set objConn = Server.CreateObject("ADODB.Connection")
    : objConn.ConnectionString=connectionStr
    : objConn.Open
    : '--------------------------------------------------------------
    : Set objRS = Server.CreateObject("ADODB.Recordset")
    :
    : strSQL="delete from rosor where id=" & request.QueryString("id")
    : objRS.Open strSQL, objConn
    :
    : objRS.Close
    : Set objRS = Nothing
    :
    : objConn.Close
    : Set objConn = Nothing
    : str="./rosor.asp?medlemsNr=" & request.QueryString("medlemsNr")
    :
    : response.Redirect(str)
    :
    : %>
    :
    :


    Ken Schaefer Guest

  4. #3

    Default Re: error when trying to delete object

    Please do not multipost. Ken just wasted his time giving you the same answer
    I already gave you in the general newsgroup. I doubt he will happy about
    this when he finds out, and it may effect his willingness to answer future
    questions from you.

    This was the correct newsgroup for this question (asp and database related).
    There was no need to post it both here and in .general

    Bob Barrows

    --
    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 Guest

  5. #4

    Default Re: error when trying to delete object

    Hi,
    sorry for my crossposting...I was a little desperate. It wont happend again!
    Please i have made som changing as u tiped me about. And i want u to look
    throu my code here. Send a different one...
    Look at my way to handle database conection etc Is this ok or should i do
    something
    different? This snip is to count click on banners on my site. Thanks for
    helping out!

    <%
    '--------------------------------------------------------------
    Response.buffer=true
    Response.ExpiresAbsolute = Now()
    Response.AddHeader "Cache-Control", "private"
    session("last_move")=time()
    '--------------------------------------------------------------
    Dim objConn ' ADO Recordset Object
    Dim objRS ' ADO Connection Object
    Dim strSQL
    Dim strSQL2
    Dim nyKlick
    '--------------------------------------------------------------
    Set objConn = Server.CreateObject("ADODB.Connection")
    objConn.ConnectionString=connectionStr
    objConn.Open
    '--------------------------------------------------------------
    strSQL="SELECT klick,url from banner where bannerId=" &
    request.querystring("id")
    Set objRS = Server.CreateObject("ADODB.Recordset")
    objRS.Open strSQL, objConn

    nyKlick=objRS("klick") +1
    redirectStr=objRS("url")

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

    Set objConn = Server.CreateObject("ADODB.Connection")
    objConn.ConnectionString=connectionStr
    objConn.Open

    strSQL2="Update banner set klick=" & nyKlick & " where bannerId=" &
    request.querystring("id")
    objConn.Execute strSQL2

    objConn.Close
    Set objConn = Nothing
    %>

    Regards Mikael



    "Ken Schaefer" <kenREMOVE@THISadOpenStatic.com> wrote in message
    news:OzsXi3hJEHA.3084@TK2MSFTNGP10.phx.gbl...
    > Recordsets are for holding records returned from the server. A DELETE
    query
    > does not return any records. Hence your recordset is not open. Hence you
    > can't call .Close()
    >
    > All you really need is the connection object:
    >
    > <%
    > Set objConn = Server.CreateObject("ADODB.Connection")
    > objConn.Open(connectionStr)
    >
    > strSQL="delete from rosor where id=" & request.QueryString("id")
    >
    > objConn.Execute(strSQL)
    > objConn.Close
    > Set objConn = Nothing
    > %>
    >
    > But you are not filtering Request.QueryString for malicious input - you
    need
    > to do that to prevent SQL Injection attacks. At the very least:
    >
    > <%
    > intID = Request.QueryString("id")
    > If not isNumeric(intID) or Len(intID) = 0 then
    > intID = -1
    > End If
    >
    > strSQL = "delete from rosor where id=" & intID
    > %>
    >
    > Cheers
    > Ken
    >
    > "Mikael Hellström" <micke.hellstrom@telia.com> wrote in message
    > news:ydRgc.56571$mU6.233598@newsb.telia.net...
    > : i get this error when i am trying to close my object after this
    operation!
    > : What can be wrong?
    > : Regards Mikael
    > :
    > : Error Type:
    > : ADODB.Recordset (0x800A0E78)
    > : Operation is not allowed when the object is closed.
    > :
    > : My code
    > :
    > : <%@ Language=VBScript%>
    > : <!-- #include file ="./connectionStr\conStr.inc" -->
    > : <%
    > : if isEmpty(session("medlemsNr")) then
    > : response.redirect("./somepage.asp")
    > : end if
    > :
    > : Response.buffer=true
    > : Response.ExpiresAbsolute = Now()
    > : Response.AddHeader "Cache-Control", "private"
    > : session("last_move")=time()
    > : '--------------------------------------------------------------
    > : Dim objConn ' ADO Recordset Object
    > : Dim objRS ' ADO Connection Object
    > : Dim strSQL
    > : '--------------------------------------------------------------
    > : Set objConn = Server.CreateObject("ADODB.Connection")
    > : objConn.ConnectionString=connectionStr
    > : objConn.Open
    > : '--------------------------------------------------------------
    > : Set objRS = Server.CreateObject("ADODB.Recordset")
    > :
    > : strSQL="delete from rosor where id=" & request.QueryString("id")
    > : objRS.Open strSQL, objConn
    > :
    > : objRS.Close
    > : Set objRS = Nothing
    > :
    > : objConn.Close
    > : Set objConn = Nothing
    > : str="./rosor.asp?medlemsNr=" & request.QueryString("medlemsNr")
    > :
    > : response.Redirect(str)
    > :
    > : %>
    > :
    > :
    >
    >

    Mikael Hellström Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139