Error "Operation is not allowed when the object is closed"

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

  1. #1

    Default Error "Operation is not allowed when the object is closed"

    The following ASP code yields the following error, but actually the new
    record is stored
    in database. The same error happens when the application deletes a record,
    such as
    sqlStmt ="delete from test where username='2323'" Any ideas? Thanks!

    <%
    Dim objRS, sqlStmt
    Set objRS = Server.CreateObject ("ADODB.Recordset")
    sqlStmt = "insert into test VALUES ('2341', '2341');"
    objRS.Open sqlStmt, strConnect
    objRS.Close
    Set objRS = Nothing
    %>

    ADODB.Recordset error '800a0e78'
    Operation is not allowed when the object is closed.





    Matthew Louden Guest

  2. Similar Questions and Discussions

    1. Operation is not allowed when the object is closed
      When I first open my ASP page, I get the error "Operation is not allowed when the object is closed" for a page containing a result set from a...
    2. Error: "The underlying connection was closed: Unable to connect to the remote server."
      We have developed a Web Service with vb.net using VS 2003 on a Windows 2003 Server. The Test application that we developed is passing 6 parameters...
    3. Operation is not allowed when the object is closed.
      i have this stored procedure... CREATE PROCEDURE p_sale_tax @locid INTEGER, @sdate VARCHAR(10), @edate VARCHAR(10) AS SET NOCOUNT ON SET @sdate...
    4. sp_executesql Operation is not allowed when the object is closed
      help! fried brains.... asp calling a sqlserver7 stored proc which dynamically builds a sqlstatement & passes it to sp_executesql asp page gives...
    5. "Connection closed by remote server" error in Opera
      I have a web site (www.on-the-matrix.com) that displays photos in a "slide show" format on ASPX pages that run in an inline frame on an ASP page (or...
  3. #2

    Default Error "Operation is not allowed when the object is closed"

    The following ASP code yields the following error, but actually the new
    record is stored
    in database. The same error happens when the application deletes a record,
    such as
    sqlStmt ="delete from test where username='2323'" Any ideas? Thanks!

    <%
    Dim objRS, sqlStmt
    Set objRS = Server.CreateObject ("ADODB.Recordset")
    sqlStmt = "insert into test VALUES ('2341', '2341');"
    objRS.Open sqlStmt, strConnect
    objRS.Close
    Set objRS = Nothing
    %>

    ADODB.Recordset error '800a0e78'
    Operation is not allowed when the object is closed.





    Matthew Louden Guest

  4. #3

    Default Re: Error "Operation is not allowed when the object is closed"

    An action statement (INSERT, UPDATE, DELETE) does not return any records,
    hence you can't close an non-open recordset. Instead, you cn do:

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

    objConn.Execute(sqlStmt)

    objConn.Close
    Set objConn = Nothing
    %>

    Also, you should not use a connection string in the .Open method of a
    recordset object, as this defeats connection pooling:

    [url]http://support.microsoft.com/?id=191572[/url]

    Cheers
    Ken

    "Matthew Louden" <jrefactors@hotmail.com> wrote in message
    news:eOQxeSLhDHA.1672@TK2MSFTNGP12.phx.gbl...
    : The following ASP code yields the following error, but actually the new
    : record is stored
    : in database. The same error happens when the application deletes a record,
    : such as
    : sqlStmt ="delete from test where username='2323'" Any ideas? Thanks!
    :
    : <%
    : Dim objRS, sqlStmt
    : Set objRS = Server.CreateObject ("ADODB.Recordset")
    : sqlStmt = "insert into test VALUES ('2341', '2341');"
    : objRS.Open sqlStmt, strConnect
    : objRS.Close
    : Set objRS = Nothing
    : %>
    :
    : ADODB.Recordset error '800a0e78'
    : Operation is not allowed when the object is closed.
    :
    :
    :
    :
    :


    Ken Schaefer Guest

  5. #4

    Default Re: Error "Operation is not allowed when the object is closed"

    An action statement (INSERT, UPDATE, DELETE) does not return any records,
    hence you can't close an non-open recordset. Instead, you cn do:

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

    objConn.Execute(sqlStmt)

    objConn.Close
    Set objConn = Nothing
    %>

    Also, you should not use a connection string in the .Open method of a
    recordset object, as this defeats connection pooling:

    [url]http://support.microsoft.com/?id=191572[/url]

    Cheers
    Ken

    "Matthew Louden" <jrefactors@hotmail.com> wrote in message
    news:eOQxeSLhDHA.1672@TK2MSFTNGP12.phx.gbl...
    : The following ASP code yields the following error, but actually the new
    : record is stored
    : in database. The same error happens when the application deletes a record,
    : such as
    : sqlStmt ="delete from test where username='2323'" Any ideas? Thanks!
    :
    : <%
    : Dim objRS, sqlStmt
    : Set objRS = Server.CreateObject ("ADODB.Recordset")
    : sqlStmt = "insert into test VALUES ('2341', '2341');"
    : objRS.Open sqlStmt, strConnect
    : objRS.Close
    : Set objRS = Nothing
    : %>
    :
    : ADODB.Recordset error '800a0e78'
    : Operation is not allowed when the object is closed.
    :
    :
    :
    :
    :


    Ken Schaefer Guest

  6. #5

    Default Re: Error "Operation is not allowed when the object is closed"

    Thanks Ken,

    I just tried it, but it yields another error on line
    objConn.Execute(sqlStmt)
    Microsoft OLE DB Provider for SQL Server error '80040e2f'

    'runners.dbo.User' ???, 'user_level' ?? NULL ?? ??? ? ????. ??? null? ??? ?
    ????. INSERT?(?) ??????.

    any ideas??



    "Ken Schaefer" <kenREMOVE@THISadOpenStatic.com> wrote in message
    news:OJtTofLhDHA.2164@TK2MSFTNGP09.phx.gbl...
    > An action statement (INSERT, UPDATE, DELETE) does not return any records,
    > hence you can't close an non-open recordset. Instead, you cn do:
    >
    > <%
    > Set objConn = Server.CreateObject("ADODB.Connection")
    > objConn.Open strConnection
    >
    > objConn.Execute(sqlStmt)
    >
    > objConn.Close
    > Set objConn = Nothing
    > %>
    >
    > Also, you should not use a connection string in the .Open method of a
    > recordset object, as this defeats connection pooling:
    >
    > [url]http://support.microsoft.com/?id=191572[/url]
    >
    > Cheers
    > Ken
    >
    > "Matthew Louden" <jrefactors@hotmail.com> wrote in message
    > news:eOQxeSLhDHA.1672@TK2MSFTNGP12.phx.gbl...
    > : The following ASP code yields the following error, but actually the new
    > : record is stored
    > : in database. The same error happens when the application deletes a
    record,
    > : such as
    > : sqlStmt ="delete from test where username='2323'" Any ideas? Thanks!
    > :
    > : <%
    > : Dim objRS, sqlStmt
    > : Set objRS = Server.CreateObject ("ADODB.Recordset")
    > : sqlStmt = "insert into test VALUES ('2341', '2341');"
    > : objRS.Open sqlStmt, strConnect
    > : objRS.Close
    > : Set objRS = Nothing
    > : %>
    > :
    > : ADODB.Recordset error '800a0e78'
    > : Operation is not allowed when the object is closed.
    > :
    > :
    > :
    > :
    > :
    >
    >

    Matthew Louden Guest

  7. #6

    Default Re: Error "Operation is not allowed when the object is closed"

    Thanks Ken,

    I just tried it, but it yields another error on line
    objConn.Execute(sqlStmt)
    Microsoft OLE DB Provider for SQL Server error '80040e2f'

    'runners.dbo.User' ???, 'user_level' ?? NULL ?? ??? ? ????. ??? null? ??? ?
    ????. INSERT?(?) ??????.

    any ideas??



    "Ken Schaefer" <kenREMOVE@THISadOpenStatic.com> wrote in message
    news:OJtTofLhDHA.2164@TK2MSFTNGP09.phx.gbl...
    > An action statement (INSERT, UPDATE, DELETE) does not return any records,
    > hence you can't close an non-open recordset. Instead, you cn do:
    >
    > <%
    > Set objConn = Server.CreateObject("ADODB.Connection")
    > objConn.Open strConnection
    >
    > objConn.Execute(sqlStmt)
    >
    > objConn.Close
    > Set objConn = Nothing
    > %>
    >
    > Also, you should not use a connection string in the .Open method of a
    > recordset object, as this defeats connection pooling:
    >
    > [url]http://support.microsoft.com/?id=191572[/url]
    >
    > Cheers
    > Ken
    >
    > "Matthew Louden" <jrefactors@hotmail.com> wrote in message
    > news:eOQxeSLhDHA.1672@TK2MSFTNGP12.phx.gbl...
    > : The following ASP code yields the following error, but actually the new
    > : record is stored
    > : in database. The same error happens when the application deletes a
    record,
    > : such as
    > : sqlStmt ="delete from test where username='2323'" Any ideas? Thanks!
    > :
    > : <%
    > : Dim objRS, sqlStmt
    > : Set objRS = Server.CreateObject ("ADODB.Recordset")
    > : sqlStmt = "insert into test VALUES ('2341', '2341');"
    > : objRS.Open sqlStmt, strConnect
    > : objRS.Close
    > : Set objRS = Nothing
    > : %>
    > :
    > : ADODB.Recordset error '800a0e78'
    > : Operation is not allowed when the object is closed.
    > :
    > :
    > :
    > :
    > :
    >
    >

    Matthew Louden Guest

  8. #7

    Default Re: Error "Operation is not allowed when the object is closed"

    I got the run-time error: Microsoft OLE DB Provider for SQL Server error
    '80040e2f'

    I read this [url]http://www.aspfaq.com/show.asp?id=2370[/url], but I am adding a
    record, not deleting a record. Since I migrate the whole web pages and
    database from one machine to another machine, it worked everything fine in
    the old machine. I already changed the connection string, and necessary
    links, but the logic should be unchanged.

    Please advise! Thanks!


    "Ken Schaefer" <kenREMOVE@THISadOpenStatic.com> wrote in message
    news:OJtTofLhDHA.2164@TK2MSFTNGP09.phx.gbl...
    > An action statement (INSERT, UPDATE, DELETE) does not return any records,
    > hence you can't close an non-open recordset. Instead, you cn do:
    >
    > <%
    > Set objConn = Server.CreateObject("ADODB.Connection")
    > objConn.Open strConnection
    >
    > objConn.Execute(sqlStmt)
    >
    > objConn.Close
    > Set objConn = Nothing
    > %>
    >
    > Also, you should not use a connection string in the .Open method of a
    > recordset object, as this defeats connection pooling:
    >
    > [url]http://support.microsoft.com/?id=191572[/url]
    >
    > Cheers
    > Ken
    >
    > "Matthew Louden" <jrefactors@hotmail.com> wrote in message
    > news:eOQxeSLhDHA.1672@TK2MSFTNGP12.phx.gbl...
    > : The following ASP code yields the following error, but actually the new
    > : record is stored
    > : in database. The same error happens when the application deletes a
    record,
    > : such as
    > : sqlStmt ="delete from test where username='2323'" Any ideas? Thanks!
    > :
    > : <%
    > : Dim objRS, sqlStmt
    > : Set objRS = Server.CreateObject ("ADODB.Recordset")
    > : sqlStmt = "insert into test VALUES ('2341', '2341');"
    > : objRS.Open sqlStmt, strConnect
    > : objRS.Close
    > : Set objRS = Nothing
    > : %>
    > :
    > : ADODB.Recordset error '800a0e78'
    > : Operation is not allowed when the object is closed.
    > :
    > :
    > :
    > :
    > :
    >
    >

    Matthew Louden Guest

  9. #8

    Default Re: Error "Operation is not allowed when the object is closed"

    I got the run-time error: Microsoft OLE DB Provider for SQL Server error
    '80040e2f'

    I read this [url]http://www.aspfaq.com/show.asp?id=2370[/url], but I am adding a
    record, not deleting a record. Since I migrate the whole web pages and
    database from one machine to another machine, it worked everything fine in
    the old machine. I already changed the connection string, and necessary
    links, but the logic should be unchanged.

    Please advise! Thanks!


    "Ken Schaefer" <kenREMOVE@THISadOpenStatic.com> wrote in message
    news:OJtTofLhDHA.2164@TK2MSFTNGP09.phx.gbl...
    > An action statement (INSERT, UPDATE, DELETE) does not return any records,
    > hence you can't close an non-open recordset. Instead, you cn do:
    >
    > <%
    > Set objConn = Server.CreateObject("ADODB.Connection")
    > objConn.Open strConnection
    >
    > objConn.Execute(sqlStmt)
    >
    > objConn.Close
    > Set objConn = Nothing
    > %>
    >
    > Also, you should not use a connection string in the .Open method of a
    > recordset object, as this defeats connection pooling:
    >
    > [url]http://support.microsoft.com/?id=191572[/url]
    >
    > Cheers
    > Ken
    >
    > "Matthew Louden" <jrefactors@hotmail.com> wrote in message
    > news:eOQxeSLhDHA.1672@TK2MSFTNGP12.phx.gbl...
    > : The following ASP code yields the following error, but actually the new
    > : record is stored
    > : in database. The same error happens when the application deletes a
    record,
    > : such as
    > : sqlStmt ="delete from test where username='2323'" Any ideas? Thanks!
    > :
    > : <%
    > : Dim objRS, sqlStmt
    > : Set objRS = Server.CreateObject ("ADODB.Recordset")
    > : sqlStmt = "insert into test VALUES ('2341', '2341');"
    > : objRS.Open sqlStmt, strConnect
    > : objRS.Close
    > : Set objRS = Nothing
    > : %>
    > :
    > : ADODB.Recordset error '800a0e78'
    > : Operation is not allowed when the object is closed.
    > :
    > :
    > :
    > :
    > :
    >
    >

    Matthew Louden Guest

  10. #9

    Default Re: Error "Operation is not allowed when the object is closed"

    Please show your revised code. we're not mind readers.

    Matthew Louden wrote:
    > I got the run-time error: Microsoft OLE DB Provider for SQL Server
    > error '80040e2f'
    >
    > I read this [url]http://www.aspfaq.com/show.asp?id=2370[/url], but I am adding a
    > record, not deleting a record. Since I migrate the whole web pages and
    > database from one machine to another machine, it worked everything
    > fine in the old machine. I already changed the connection string, and
    > necessary links, but the logic should be unchanged.
    >
    > Please advise! Thanks!
    >
    >
    > "Ken Schaefer" <kenREMOVE@THISadOpenStatic.com> wrote in message
    > news:OJtTofLhDHA.2164@TK2MSFTNGP09.phx.gbl...
    >> An action statement (INSERT, UPDATE, DELETE) does not return any
    >> records, hence you can't close an non-open recordset. Instead, you
    >> cn do:
    >>
    >> <%
    >> Set objConn = Server.CreateObject("ADODB.Connection")
    >> objConn.Open strConnection
    >>
    >> objConn.Execute(sqlStmt)
    >>
    >> objConn.Close
    >> Set objConn = Nothing
    >> %>
    >>
    >> Also, you should not use a connection string in the .Open method of a
    >> recordset object, as this defeats connection pooling:
    >>
    >> [url]http://support.microsoft.com/?id=191572[/url]
    >>
    >> Cheers
    >> Ken
    >>
    >> "Matthew Louden" <jrefactors@hotmail.com> wrote in message
    >> news:eOQxeSLhDHA.1672@TK2MSFTNGP12.phx.gbl...
    >>> The following ASP code yields the following error, but actually the
    >>> new record is stored
    >>> in database. The same error happens when the application deletes a
    >>> record, such as
    >>> sqlStmt ="delete from test where username='2323'" Any ideas?
    >>> Thanks!
    >>>
    >>> <%
    >>> Dim objRS, sqlStmt
    >>> Set objRS = Server.CreateObject ("ADODB.Recordset")
    >>> sqlStmt = "insert into test VALUES ('2341', '2341');"
    >>> objRS.Open sqlStmt, strConnect
    >>> objRS.Close
    >>> Set objRS = Nothing
    >>> %>
    >>>
    >>> ADODB.Recordset error '800a0e78'
    >>> Operation is not allowed when the object is closed.


    Bob Barrows Guest

  11. #10

    Default Re: Error "Operation is not allowed when the object is closed"

    Please show your revised code. we're not mind readers.

    Matthew Louden wrote:
    > I got the run-time error: Microsoft OLE DB Provider for SQL Server
    > error '80040e2f'
    >
    > I read this [url]http://www.aspfaq.com/show.asp?id=2370[/url], but I am adding a
    > record, not deleting a record. Since I migrate the whole web pages and
    > database from one machine to another machine, it worked everything
    > fine in the old machine. I already changed the connection string, and
    > necessary links, but the logic should be unchanged.
    >
    > Please advise! Thanks!
    >
    >
    > "Ken Schaefer" <kenREMOVE@THISadOpenStatic.com> wrote in message
    > news:OJtTofLhDHA.2164@TK2MSFTNGP09.phx.gbl...
    >> An action statement (INSERT, UPDATE, DELETE) does not return any
    >> records, hence you can't close an non-open recordset. Instead, you
    >> cn do:
    >>
    >> <%
    >> Set objConn = Server.CreateObject("ADODB.Connection")
    >> objConn.Open strConnection
    >>
    >> objConn.Execute(sqlStmt)
    >>
    >> objConn.Close
    >> Set objConn = Nothing
    >> %>
    >>
    >> Also, you should not use a connection string in the .Open method of a
    >> recordset object, as this defeats connection pooling:
    >>
    >> [url]http://support.microsoft.com/?id=191572[/url]
    >>
    >> Cheers
    >> Ken
    >>
    >> "Matthew Louden" <jrefactors@hotmail.com> wrote in message
    >> news:eOQxeSLhDHA.1672@TK2MSFTNGP12.phx.gbl...
    >>> The following ASP code yields the following error, but actually the
    >>> new record is stored
    >>> in database. The same error happens when the application deletes a
    >>> record, such as
    >>> sqlStmt ="delete from test where username='2323'" Any ideas?
    >>> Thanks!
    >>>
    >>> <%
    >>> Dim objRS, sqlStmt
    >>> Set objRS = Server.CreateObject ("ADODB.Recordset")
    >>> sqlStmt = "insert into test VALUES ('2341', '2341');"
    >>> objRS.Open sqlStmt, strConnect
    >>> objRS.Close
    >>> Set objRS = Nothing
    >>> %>
    >>>
    >>> ADODB.Recordset error '800a0e78'
    >>> Operation is not allowed when the object is closed.


    Bob Barrows Guest

  12. #11

    Default Re: Error "Operation is not allowed when the object is closed"

    I got the run-time error: Microsoft OLE DB Provider for SQL Server error
    '80040e2f' on line
    conn.Execute(InsertUsersSql)

    Here's the code fragment:
    <%
    Set conn = Server.CreateObject ("ADODB.Connection")
    conn.Open strConnect
    InsertUsersSql= "Insert Into Users VALUES ('myusername', 'mypassword');"
    Response.Write InsertUsersSql
    conn.Execute(InsertUsersSql)
    conn.Close
    Set conn = Nothing
    %>

    I read this [url]http://www.aspfaq.com/show.asp?id=2370[/url], but I am adding a
    record, not deleting a record. Any ideas??

    "Bob Barrows" <reb01501@NOyahoo.SPAMcom> wrote in message
    news:OBGJJpShDHA.2516@TK2MSFTNGP09.phx.gbl...
    > Please show your revised code. we're not mind readers.
    >
    > Matthew Louden wrote:
    > > I got the run-time error: Microsoft OLE DB Provider for SQL Server
    > > error '80040e2f'
    > >
    > > I read this [url]http://www.aspfaq.com/show.asp?id=2370[/url], but I am adding a
    > > record, not deleting a record. Since I migrate the whole web pages and
    > > database from one machine to another machine, it worked everything
    > > fine in the old machine. I already changed the connection string, and
    > > necessary links, but the logic should be unchanged.
    > >
    > > Please advise! Thanks!
    > >
    > >
    > > "Ken Schaefer" <kenREMOVE@THISadOpenStatic.com> wrote in message
    > > news:OJtTofLhDHA.2164@TK2MSFTNGP09.phx.gbl...
    > >> An action statement (INSERT, UPDATE, DELETE) does not return any
    > >> records, hence you can't close an non-open recordset. Instead, you
    > >> cn do:
    > >>
    > >> <%
    > >> Set objConn = Server.CreateObject("ADODB.Connection")
    > >> objConn.Open strConnection
    > >>
    > >> objConn.Execute(sqlStmt)
    > >>
    > >> objConn.Close
    > >> Set objConn = Nothing
    > >> %>
    > >>
    > >> Also, you should not use a connection string in the .Open method of a
    > >> recordset object, as this defeats connection pooling:
    > >>
    > >> [url]http://support.microsoft.com/?id=191572[/url]
    > >>
    > >> Cheers
    > >> Ken
    > >>
    > >> "Matthew Louden" <jrefactors@hotmail.com> wrote in message
    > >> news:eOQxeSLhDHA.1672@TK2MSFTNGP12.phx.gbl...
    > >>> The following ASP code yields the following error, but actually the
    > >>> new record is stored
    > >>> in database. The same error happens when the application deletes a
    > >>> record, such as
    > >>> sqlStmt ="delete from test where username='2323'" Any ideas?
    > >>> Thanks!
    > >>>
    > >>> <%
    > >>> Dim objRS, sqlStmt
    > >>> Set objRS = Server.CreateObject ("ADODB.Recordset")
    > >>> sqlStmt = "insert into test VALUES ('2341', '2341');"
    > >>> objRS.Open sqlStmt, strConnect
    > >>> objRS.Close
    > >>> Set objRS = Nothing
    > >>> %>
    > >>>
    > >>> ADODB.Recordset error '800a0e78'
    > >>> Operation is not allowed when the object is closed.
    >
    >
    >

    Matthew Louden Guest

  13. #12

    Default Re: Error "Operation is not allowed when the object is closed"

    I got the run-time error: Microsoft OLE DB Provider for SQL Server error
    '80040e2f' on line
    conn.Execute(InsertUsersSql)

    Here's the code fragment:
    <%
    Set conn = Server.CreateObject ("ADODB.Connection")
    conn.Open strConnect
    InsertUsersSql= "Insert Into Users VALUES ('myusername', 'mypassword');"
    Response.Write InsertUsersSql
    conn.Execute(InsertUsersSql)
    conn.Close
    Set conn = Nothing
    %>

    I read this [url]http://www.aspfaq.com/show.asp?id=2370[/url], but I am adding a
    record, not deleting a record. Any ideas??

    "Bob Barrows" <reb01501@NOyahoo.SPAMcom> wrote in message
    news:OBGJJpShDHA.2516@TK2MSFTNGP09.phx.gbl...
    > Please show your revised code. we're not mind readers.
    >
    > Matthew Louden wrote:
    > > I got the run-time error: Microsoft OLE DB Provider for SQL Server
    > > error '80040e2f'
    > >
    > > I read this [url]http://www.aspfaq.com/show.asp?id=2370[/url], but I am adding a
    > > record, not deleting a record. Since I migrate the whole web pages and
    > > database from one machine to another machine, it worked everything
    > > fine in the old machine. I already changed the connection string, and
    > > necessary links, but the logic should be unchanged.
    > >
    > > Please advise! Thanks!
    > >
    > >
    > > "Ken Schaefer" <kenREMOVE@THISadOpenStatic.com> wrote in message
    > > news:OJtTofLhDHA.2164@TK2MSFTNGP09.phx.gbl...
    > >> An action statement (INSERT, UPDATE, DELETE) does not return any
    > >> records, hence you can't close an non-open recordset. Instead, you
    > >> cn do:
    > >>
    > >> <%
    > >> Set objConn = Server.CreateObject("ADODB.Connection")
    > >> objConn.Open strConnection
    > >>
    > >> objConn.Execute(sqlStmt)
    > >>
    > >> objConn.Close
    > >> Set objConn = Nothing
    > >> %>
    > >>
    > >> Also, you should not use a connection string in the .Open method of a
    > >> recordset object, as this defeats connection pooling:
    > >>
    > >> [url]http://support.microsoft.com/?id=191572[/url]
    > >>
    > >> Cheers
    > >> Ken
    > >>
    > >> "Matthew Louden" <jrefactors@hotmail.com> wrote in message
    > >> news:eOQxeSLhDHA.1672@TK2MSFTNGP12.phx.gbl...
    > >>> The following ASP code yields the following error, but actually the
    > >>> new record is stored
    > >>> in database. The same error happens when the application deletes a
    > >>> record, such as
    > >>> sqlStmt ="delete from test where username='2323'" Any ideas?
    > >>> Thanks!
    > >>>
    > >>> <%
    > >>> Dim objRS, sqlStmt
    > >>> Set objRS = Server.CreateObject ("ADODB.Recordset")
    > >>> sqlStmt = "insert into test VALUES ('2341', '2341');"
    > >>> objRS.Open sqlStmt, strConnect
    > >>> objRS.Close
    > >>> Set objRS = Nothing
    > >>> %>
    > >>>
    > >>> ADODB.Recordset error '800a0e78'
    > >>> Operation is not allowed when the object is closed.
    >
    >
    >

    Matthew Louden Guest

  14. #13

    Default Re: Error "Operation is not allowed when the object is closed"

    What columns do you have in the table Users? If there are more than two,
    then do:

    InsertUsersSql = _
    "INSERT INTO Users (field1, field2) & _
    "VALUES ('myusername', 'mypassword');"

    (changing field1, and field2 to be the names of the fields you want the
    values inserted into)

    Cheers
    Ken


    "Matthew Louden" <jrefactors@hotmail.com> wrote in message
    news:e$jUR5ThDHA.2512@TK2MSFTNGP09.phx.gbl...
    : I got the run-time error: Microsoft OLE DB Provider for SQL Server error
    : '80040e2f' on line
    : conn.Execute(InsertUsersSql)
    :
    : Here's the code fragment:
    : <%
    : Set conn = Server.CreateObject ("ADODB.Connection")
    : conn.Open strConnect
    : InsertUsersSql= "Insert Into Users VALUES ('myusername', 'mypassword');"
    : Response.Write InsertUsersSql
    : conn.Execute(InsertUsersSql)
    : conn.Close
    : Set conn = Nothing
    : %>
    :
    : I read this [url]http://www.aspfaq.com/show.asp?id=2370[/url], but I am adding a
    : record, not deleting a record. Any ideas??
    :
    : "Bob Barrows" <reb01501@NOyahoo.SPAMcom> wrote in message
    : news:OBGJJpShDHA.2516@TK2MSFTNGP09.phx.gbl...
    : > Please show your revised code. we're not mind readers.
    : >
    : > Matthew Louden wrote:
    : > > I got the run-time error: Microsoft OLE DB Provider for SQL Server
    : > > error '80040e2f'
    : > >
    : > > I read this [url]http://www.aspfaq.com/show.asp?id=2370[/url], but I am adding a
    : > > record, not deleting a record. Since I migrate the whole web pages and
    : > > database from one machine to another machine, it worked everything
    : > > fine in the old machine. I already changed the connection string, and
    : > > necessary links, but the logic should be unchanged.
    : > >
    : > > Please advise! Thanks!
    : > >
    : > >
    : > > "Ken Schaefer" <kenREMOVE@THISadOpenStatic.com> wrote in message
    : > > news:OJtTofLhDHA.2164@TK2MSFTNGP09.phx.gbl...
    : > >> An action statement (INSERT, UPDATE, DELETE) does not return any
    : > >> records, hence you can't close an non-open recordset. Instead, you
    : > >> cn do:
    : > >>
    : > >> <%
    : > >> Set objConn = Server.CreateObject("ADODB.Connection")
    : > >> objConn.Open strConnection
    : > >>
    : > >> objConn.Execute(sqlStmt)
    : > >>
    : > >> objConn.Close
    : > >> Set objConn = Nothing
    : > >> %>
    : > >>
    : > >> Also, you should not use a connection string in the .Open method of a
    : > >> recordset object, as this defeats connection pooling:
    : > >>
    : > >> [url]http://support.microsoft.com/?id=191572[/url]
    : > >>
    : > >> Cheers
    : > >> Ken
    : > >>
    : > >> "Matthew Louden" <jrefactors@hotmail.com> wrote in message
    : > >> news:eOQxeSLhDHA.1672@TK2MSFTNGP12.phx.gbl...
    : > >>> The following ASP code yields the following error, but actually the
    : > >>> new record is stored
    : > >>> in database. The same error happens when the application deletes a
    : > >>> record, such as
    : > >>> sqlStmt ="delete from test where username='2323'" Any ideas?
    : > >>> Thanks!
    : > >>>
    : > >>> <%
    : > >>> Dim objRS, sqlStmt
    : > >>> Set objRS = Server.CreateObject ("ADODB.Recordset")
    : > >>> sqlStmt = "insert into test VALUES ('2341', '2341');"
    : > >>> objRS.Open sqlStmt, strConnect
    : > >>> objRS.Close
    : > >>> Set objRS = Nothing
    : > >>> %>
    : > >>>
    : > >>> ADODB.Recordset error '800a0e78'
    : > >>> Operation is not allowed when the object is closed.
    : >
    : >
    : >
    :
    :


    Ken Schaefer Guest

  15. #14

    Default Re: Error "Operation is not allowed when the object is closed"

    What columns do you have in the table Users? If there are more than two,
    then do:

    InsertUsersSql = _
    "INSERT INTO Users (field1, field2) & _
    "VALUES ('myusername', 'mypassword');"

    (changing field1, and field2 to be the names of the fields you want the
    values inserted into)

    Cheers
    Ken


    "Matthew Louden" <jrefactors@hotmail.com> wrote in message
    news:e$jUR5ThDHA.2512@TK2MSFTNGP09.phx.gbl...
    : I got the run-time error: Microsoft OLE DB Provider for SQL Server error
    : '80040e2f' on line
    : conn.Execute(InsertUsersSql)
    :
    : Here's the code fragment:
    : <%
    : Set conn = Server.CreateObject ("ADODB.Connection")
    : conn.Open strConnect
    : InsertUsersSql= "Insert Into Users VALUES ('myusername', 'mypassword');"
    : Response.Write InsertUsersSql
    : conn.Execute(InsertUsersSql)
    : conn.Close
    : Set conn = Nothing
    : %>
    :
    : I read this [url]http://www.aspfaq.com/show.asp?id=2370[/url], but I am adding a
    : record, not deleting a record. Any ideas??
    :
    : "Bob Barrows" <reb01501@NOyahoo.SPAMcom> wrote in message
    : news:OBGJJpShDHA.2516@TK2MSFTNGP09.phx.gbl...
    : > Please show your revised code. we're not mind readers.
    : >
    : > Matthew Louden wrote:
    : > > I got the run-time error: Microsoft OLE DB Provider for SQL Server
    : > > error '80040e2f'
    : > >
    : > > I read this [url]http://www.aspfaq.com/show.asp?id=2370[/url], but I am adding a
    : > > record, not deleting a record. Since I migrate the whole web pages and
    : > > database from one machine to another machine, it worked everything
    : > > fine in the old machine. I already changed the connection string, and
    : > > necessary links, but the logic should be unchanged.
    : > >
    : > > Please advise! Thanks!
    : > >
    : > >
    : > > "Ken Schaefer" <kenREMOVE@THISadOpenStatic.com> wrote in message
    : > > news:OJtTofLhDHA.2164@TK2MSFTNGP09.phx.gbl...
    : > >> An action statement (INSERT, UPDATE, DELETE) does not return any
    : > >> records, hence you can't close an non-open recordset. Instead, you
    : > >> cn do:
    : > >>
    : > >> <%
    : > >> Set objConn = Server.CreateObject("ADODB.Connection")
    : > >> objConn.Open strConnection
    : > >>
    : > >> objConn.Execute(sqlStmt)
    : > >>
    : > >> objConn.Close
    : > >> Set objConn = Nothing
    : > >> %>
    : > >>
    : > >> Also, you should not use a connection string in the .Open method of a
    : > >> recordset object, as this defeats connection pooling:
    : > >>
    : > >> [url]http://support.microsoft.com/?id=191572[/url]
    : > >>
    : > >> Cheers
    : > >> Ken
    : > >>
    : > >> "Matthew Louden" <jrefactors@hotmail.com> wrote in message
    : > >> news:eOQxeSLhDHA.1672@TK2MSFTNGP12.phx.gbl...
    : > >>> The following ASP code yields the following error, but actually the
    : > >>> new record is stored
    : > >>> in database. The same error happens when the application deletes a
    : > >>> record, such as
    : > >>> sqlStmt ="delete from test where username='2323'" Any ideas?
    : > >>> Thanks!
    : > >>>
    : > >>> <%
    : > >>> Dim objRS, sqlStmt
    : > >>> Set objRS = Server.CreateObject ("ADODB.Recordset")
    : > >>> sqlStmt = "insert into test VALUES ('2341', '2341');"
    : > >>> objRS.Open sqlStmt, strConnect
    : > >>> objRS.Close
    : > >>> Set objRS = Nothing
    : > >>> %>
    : > >>>
    : > >>> ADODB.Recordset error '800a0e78'
    : > >>> Operation is not allowed when the object is closed.
    : >
    : >
    : >
    :
    :


    Ken Schaefer 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