The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages - More
> ASP Programming
|
800a0e78 - Operation is not allowed when the object is closed
Discuss 800a0e78 - Operation is not allowed when the object is closed in the ASP Programming forum on Dev Shed. 800a0e78 - Operation is not allowed when the object is closed ASP Programming forum discussing Active Server Pages coding techniques and problem solving methods. Use VBScript or Jscript to make dynamic web applications.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

November 25th, 2003, 10:16 AM
|
|
Registered User
|
|
Join Date: Nov 2003
Posts: 3
Time spent in forums: 3 m 35 sec
Reputation Power: 0
|
|
|
800a0e78 - Operation is not allowed when the object is closed
I get the error "ADODB.Recordset error '800a0e78' - Operation is not allowed when the object is closed" when I try to check if I've reached EOF with my returned recordset. It works perfectly in query analyzer, perhaps the parameters (smalldatetime fields) need to be formatted differently through ASP?
' DB Connection
Dim connString, conn, spName, cmd, rs
' dbConn() is a function to auto create the connection string - it works
connString = dbConn("MCRF", "Research_Support", "I")
Set conn = Server.CreateObject("ADODB.Connection")
conn.open(connString)
Set cmd = Server.CreateObject("ADODB.Command")
Set cmd.ActiveConnection = conn
cmd.CommandType = 4 '// 4 means that the command is a stored procedure name
spName = "usp_myStoredProcedure"
cmd.CommandText = spName
cmd.Parameters(1) = "10/01/2001 12:00:01 AM"
cmd.Parameters(2) = "9/30/2003 11:59:59 PM"
' State is open.
Response.Write(cmd.State)
Set rs = cmd.Execute()
' Tried just in case...same error though
'Set rs = Conn.Execute ("EXEC usp_myStoredProcedure @BeginDate='10/01/2001 12:00:01 AM', @EndDate='9/30/2002 11:59:59 PM'")
' This is where it fails.
If NOT rs.EOF Then
' The rest of my page begins here...
|

November 25th, 2003, 11:04 AM
|
|
Contributing User
|
|
Join Date: Nov 2003
Location: Ohio
Posts: 30
Time spent in forums: 1 h 41 m 6 sec
Reputation Power: 10
|
|
Your problem looks to be here:
Instead what you need to do is this:
That should solve your problem. Just remember to close your connection when you are done so you do not waste those system resources.
|

November 25th, 2003, 11:19 AM
|
|
Contributing User
|
|
Join Date: Nov 2003
Location: Ohio
Posts: 30
Time spent in forums: 1 h 41 m 6 sec
Reputation Power: 10
|
|
You might also have a problem with this line too:
I'm really not the one to let you know how to fix this though.
I set my db calls in a different fashion. This is how I go about setting up a recordset:
PHP Code:
set rsName = server.createobject("ADODB.Recordset")
sqlstatement = "SELECT ....."
rsName.Open sqlstatement, dbConnection, 0, 1
if not rsName.eof and not rsName.bof then
rsName.movefirst
variableName1 = rsName.fields("fieldName")
end if
rsName.Close
set rsName = nothing
dbConnection is where I set my connection to my db in a file I include on any page that makes a call to the database. Setting my recordsets up this way I have run into very few problems. along the way.
I think my earlier advice might help out some but I don't think it will get it working 100% for you. I'm sure someone else out there will have a more complete answer for you. Hope this helps some.
|

November 25th, 2003, 12:25 PM
|
|
Contributing User
|
|
Join Date: Nov 2003
Posts: 120
Time spent in forums: 30 m 57 sec
Reputation Power: 10
|
|
|
not real sure about this, but does smalldatetime support AM/PM format or does it use military time (ie, 5:00 PM = 17:00)?
you could try dropping the AM/PM and just doing it in 24 hr format - see if that works.
just a suggestion, 5% chance of me being right - but worth a try i suppose.
|

November 25th, 2003, 12:47 PM
|
|
Registered User
|
|
Join Date: Nov 2003
Posts: 3
Time spent in forums: 3 m 35 sec
Reputation Power: 0
|
|
Thank you for the assistance everyone - it turns out a table in the stored procedure had a permissions problem. Our DBA is looking into the issue now, hopefully that will resolve it. The reason my code was failing was because an empty recordset was being sent back, if anyone knows a better way to trap that error than the rs.EOF (Which doesn't work with an empty recordset apparently  -- please let me know.
|

November 25th, 2003, 03:50 PM
|
|
Contributing User
|
|
Join Date: Nov 2003
Posts: 120
Time spent in forums: 30 m 57 sec
Reputation Power: 10
|
|
|
i'm not sure of the State of a recordset if nothing is returned.... try a response.write of the recordset state -- if it's not Open then you can just check that.
|

December 4th, 2006, 10:43 AM
|
|
Registered User
|
|
Join Date: Dec 2006
Posts: 1
Time spent in forums: 7 m 34 sec
Reputation Power: 0
|
|
|
Set nocount on
I believe this will fix your problem. Just put in the stored procedure SET NOCOUNT ON and it removes the header information that sql sends before it actually sets the data that you loop through in asp. Do a search for SET NOCOUNT ON for a more percise explanation. This fixed our problem.
|

December 4th, 2006, 11:15 AM
|
|
Registered User
|
|
Join Date: Nov 2003
Posts: 3
Time spent in forums: 3 m 35 sec
Reputation Power: 0
|
|
Update
Quote: | Originally Posted by LAF I believe this will fix your problem. Just put in the stored procedure SET NOCOUNT ON and it removes the header information that sql sends before it actually sets the data that you loop through in asp. Do a search for SET NOCOUNT ON for a more percise explanation. This fixed our problem. |
Please see above, it was simply a permissions issue on the table. Gotta love error handling with vbscript. Thanks for the assist though!
|

June 6th, 2007, 02:33 PM
|
|
Registered User
|
|
Join Date: Dec 2005
Posts: 3
Time spent in forums: 8 m 53 sec
Reputation Power: 0
|
|
|
thank you!!!
Thank you so much for this response. I've been banging my head trying to figure out what this problem was and all it took to fix it was to Set NoCount on setting in my storedprocedure.
Thanks for the help!!
|

June 10th, 2009, 04:30 AM
|
|
Registered User
|
|
Join Date: Jun 2009
Posts: 1
Time spent in forums: 9 m 14 sec
Reputation Power: 0
|
|
|
Wow, thank you very much LAF. I've been hours working on this error. Simply putting Set Nocount ON on my Stored Procedure bright up my day.
|

May 3rd, 2012, 02:02 PM
|
|
Registered User
|
|
Join Date: May 2012
Posts: 1
Time spent in forums: 9 m 58 sec
Reputation Power: 0
|
|
Quote: | Originally Posted by LAF I believe this will fix your problem. Just put in the stored procedure SET NOCOUNT ON and it removes the header information that sql sends before it actually sets the data that you loop through in asp. Do a search for SET NOCOUNT ON for a more percise explanation. This fixed our problem. |
Thankyou very much, this solve the problem in my case
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|