Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / ASP / Database Access / September 2003



Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Matthew Louden - 27 Sep 2003 06:05 GMT
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 - 27 Sep 2003 06:26 GMT
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

: The following ASP code yields the following error, but actually the new
: record is stored
[quoted text clipped - 13 lines]
: ADODB.Recordset error '800a0e78'
: Operation is not allowed when the object is closed.
Matthew Louden - 27 Sep 2003 19:30 GMT
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??

> An action statement (INSERT, UPDATE, DELETE) does not return any records,
> hence you can't close an non-open recordset. Instead, you cn do:
[quoted text clipped - 34 lines]
> : ADODB.Recordset error '800a0e78'
> : Operation is not allowed when the object is closed.
Matthew Louden - 27 Sep 2003 19:33 GMT
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!

> An action statement (INSERT, UPDATE, DELETE) does not return any records,
> hence you can't close an non-open recordset. Instead, you cn do:
[quoted text clipped - 34 lines]
> : ADODB.Recordset error '800a0e78'
> : Operation is not allowed when the object is closed.
Bob Barrows - 27 Sep 2003 20:05 GMT
Please show your revised code. we're not mind readers.

> I got the run-time error: Microsoft OLE DB Provider for SQL Server
> error '80040e2f'
[quoted text clipped - 47 lines]
>>> ADODB.Recordset error '800a0e78'
>>> Operation is not allowed when the object is closed.
Matthew Louden - 27 Sep 2003 22:31 GMT
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??

> Please show your revised code. we're not mind readers.
>
[quoted text clipped - 49 lines]
> >>> ADODB.Recordset error '800a0e78'
> >>> Operation is not allowed when the object is closed.
Ken Schaefer - 28 Sep 2003 03:26 GMT
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

: I got the run-time error: Microsoft OLE DB Provider for SQL Server error
: '80040e2f' on  line
[quoted text clipped - 67 lines]
: > >>> ADODB.Recordset error '800a0e78'
: > >>> Operation is not allowed when the object is closed.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.