Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error: '800a0e78' object is closed?

Status
Not open for further replies.

BrainLeech

Programmer
Mar 13, 2001
1
US
I have a problem with one of my pages not connecting to the SQL database. This is the error I recieve when attempting to view the page:

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

This is the code that is producing the error:

Code:
<%
Dim conn 
Dim rsDocuments 

set conn = server.CreateObject(&quot;adodb.connection&quot;)
set rsDocuments = server.CreateObject(&quot;adodb.recordset&quot;)

rsDocuments.Open &quot;SELECT ID FROM tblDocuments WHERE IDStudent=&quot; & session(&quot;IDStudent&quot;), conn,adOpenKeyset,adLockReadOnly

dim numDocs
numdocs = rsDocuments.RecordCount

if not rsDocuments.BOF then
   dim FldID
   set FldID=rsDocuments(&quot;id&quot;)
   do while not rsDocuments.EOF
%>

I assume that I am missing a simple line of information or something, but I am new to both SQL and ASP. If more code or info is needed let me know.
 
You have a few things wrong --

First off, you never opened your connection. To do so, you need to either set up a DSN on the server, or else build up your connection string and then open the connection.

Secondly, the adOpenKeyset and adLockReadOnly properties are for the recordset, and need to be set before you open it

rsDocuments.lockType = adLockReadOnly
rsDocuments.cursorType = adOpenKeyset

And the above is assuming that you have included the adovbs.inc file (or declared the constants yourself). Otherwise, you need to use the integer values that correspond to those constants.

You also forgot to set your activeconnection property of your recordset.

I'm not sure what you are trying to accomplish with that SELECT statement with your conn variable and whatnot all thrown in there together. That's definitely erroneous.

Try the above changes and post the results (inluding the line number where your error is occuring this time), and I'm sure we can work the rest of it out.

Just for reference sake, I'll add some code here of what a good connection and recordset creation would look like:
Code:
dim conn, rsDocuments
set conn = server.createobject(&quot;ADODB.Connection&quot;)
set rsDocuments = server.createobject(&quot;ADODB.Recordset&quot;)

conn.open (&quot;DSN=myDSN&quot;) 'myDSN being the name of the DSN

rsDocuments.lockType = adLockReadOnly
rsDocuments.cursorType = adOpenKeyset
rsDocuments.activeConnection = conn

rsDocuments.open (&quot;SELECT * FROM theTable WHERE whatever&quot;

good luck!:)
Paul Prewett
 
Obviously, I was a little off last night when I made that post. I now see what you were doing with the rsDocuments open statement. I must have been asleep...

Just not the way I do it, so I wasn't thinking straight.

The problem was that your connection was never opened, and that must have been where your error was popping up.

Sorry for the mixup:)
Paul Prewett
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top