ms sql 2005 asp script error closed recordset

th script below runs ok. It runs periodically.

Sometimes on the line
if not EmailRS.eof then
I get an error: operation not available with object closed.
akes it to that
My script (supposedly) opens the record set and if it fails to open  exits the loop not reaching the if not EmailRS.eof thenoffending  line.

The logic of the code (supposedly) that line only if the recorset if open.

Any ideas?
do while true
Set EmailRS = Server.CreateObject("ADODB.RecordSet")
sql="select top 1 * from servicio_proyecto where  ok=0 and initiate=1  order by project desc,id"
on error resume next
EmailRS.Open sql, cn
if Err.Number>0 then
on error goto 0
exit do
end if
on error goto 0
if not EmailRS.eof then
end if
loop

Open in new window

robrodpAsked:
Who is Participating?
 
BrandonGalderisiConnect With a Mentor Commented:
Obviously error.number>0 is NOT working.  I've commented that out and placed a wscript.echo in to put the value of err.number to screen.  
do while true
Set EmailRS = Server.CreateObject("ADODB.RecordSet")
sql="select top 1 * from servicio_proyecto where  ok=0 and initiate=1  order by project desc,id"
'on error resume next
EmailRS.Open sql, cn
wscript.echo "ERR=" & err.Number & "=END ERROR<br/>"
if Err.Number>0 then
on error goto 0
exit do
end if
on error goto 0
if not EmailRS.eof then
end if
loop

Open in new window

0
 
robrodpAuthor Commented:
After your comment I checked and found there was no close for the EmailRS. I have included the close and will see if it solves the problem
0
 
BrandonGalderisiCommented:
The error "operation not available with object closed" indicates that the object is not OPEN, not that you didn't CLOSE it.  Some sort of error is happening on line 5 of your code when attempting to open the connection.  Commenting out the "on error resume next" will tell you what.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.