Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Error "Operation is not allowed when the object is closed"

Reply
Thread Tools

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

 
 
Matthew Louden
Guest
Posts: n/a
 
      09-27-2003
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.





 
Reply With Quote
 
 
 
 
Ken Schaefer
Guest
Posts: n/a
 
      09-27-2003
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:

http://support.microsoft.com/?id=191572

Cheers
Ken

"Matthew Louden" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
: 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.
:
:
:
:
:


 
Reply With Quote
 
 
 
 
Matthew Louden
Guest
Posts: n/a
 
      09-27-2003
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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:
>
> http://support.microsoft.com/?id=191572
>
> Cheers
> Ken
>
> "Matthew Louden" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> : 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.
> :
> :
> :
> :
> :
>
>



 
Reply With Quote
 
Matthew Louden
Guest
Posts: n/a
 
      09-27-2003
I got the run-time error: Microsoft OLE DB Provider for SQL Server error
'80040e2f'

I read this http://www.aspfaq.com/show.asp?id=2370, 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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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:
>
> http://support.microsoft.com/?id=191572
>
> Cheers
> Ken
>
> "Matthew Louden" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> : 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.
> :
> :
> :
> :
> :
>
>



 
Reply With Quote
 
Bob Barrows
Guest
Posts: n/a
 
      09-27-2003
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 http://www.aspfaq.com/show.asp?id=2370, 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> 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:
>>
>> http://support.microsoft.com/?id=191572
>>
>> Cheers
>> Ken
>>
>> "Matthew Louden" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> 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.




 
Reply With Quote
 
Matthew Louden
Guest
Posts: n/a
 
      09-27-2003
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 http://www.aspfaq.com/show.asp?id=2370, but I am adding a
record, not deleting a record. Any ideas??

"Bob Barrows" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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 http://www.aspfaq.com/show.asp?id=2370, 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" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> >> 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:
> >>
> >> http://support.microsoft.com/?id=191572
> >>
> >> Cheers
> >> Ken
> >>
> >> "Matthew Louden" <(E-Mail Removed)> wrote in message
> >> news:(E-Mail Removed)...
> >>> 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.

>
>
>



 
Reply With Quote
 
Ken Schaefer
Guest
Posts: n/a
 
      09-28-2003
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" <(E-Mail Removed)> wrote in message
news:e$(E-Mail Removed)...
: 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 http://www.aspfaq.com/show.asp?id=2370, but I am adding a
: record, not deleting a record. Any ideas??
:
: "Bob Barrows" <(E-Mail Removed)> wrote in message
: news:(E-Mail Removed)...
: > 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 http://www.aspfaq.com/show.asp?id=2370, 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" <(E-Mail Removed)> wrote in message
: > > news:(E-Mail Removed)...
: > >> 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:
: > >>
: > >> http://support.microsoft.com/?id=191572
: > >>
: > >> Cheers
: > >> Ken
: > >>
: > >> "Matthew Louden" <(E-Mail Removed)> wrote in message
: > >> news:(E-Mail Removed)...
: > >>> 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.
: >
: >
: >
:
:


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why defining a constant in a method is not allowed but usingself.class.const_set is allowed? IƱaki Baz Castillo Ruby 13 05-01-2011 06:09 PM
While executing the class definition which object is referenced bythe first argument of the class method, Y r Object attributes not allowed asdefault arguments Krishna Python 4 03-07-2008 09:44 PM
asp to asp.net operation not allowed when object is closed amitbadgi@gmail.com ASP .Net 1 08-10-2005 11:36 AM
"operation is not allowed when the object is closed" error when using VBA online help -- Resolution TC ASP General 1 01-12-2005 09:05 AM
Msxml2.XMLHTTP object's send method throwing HTTP /1.1 405 - Method not allowed error. RK Javascript 5 08-08-2004 08:52 PM



Advertisments