The following code, is generating that error.
Set getList = Server.CreateObject("ADODB.Command")
getList.ActiveConnection=EV_WikiConn
getList.Prepared = true
getList.commandtext= "declare @Lookup table(Id int identity(1, 1) , SongTitle nvarchar(512) )
insert into @Lookup(SongTitle)select * from ( values ('Deuce')) as x(a)
select A.AlbumName, S.SongTitle , S.Writers , S.Vocals , S.SID , S.TheTime
from Albums A inner join Songs S on A.AID = S.AID inner join @Lookup L on L.SongTitle = S.SongTitle order by L.Id"
set rsList = getList.execute
while not rsList.eof ' Error is on this line here.
I added this code here
Set getList = Server.CreateObject("ADODB.Command")
getList.ActiveConnection=EV_WikiConn
getList.Prepared = true
getList.commandtext= "declare @Lookup table(Id int identity(1, 1) , SongTitle nvarchar(512) )
insert into @Lookup(SongTitle)select * from ( values ('Deuce'),('Strutter'),('Parasite')) as x(a)
select A.AlbumName, S.SongTitle , S.Writers , S.Vocals , S.SID , S.TheTime
from Albums A inner join Songs S on A.AID = S.AID inner join @Lookup L on L.SongTitle = S.SongTitle order by L.Id"
set rsList = getList.execute
If rsList.State <> adStateOpen Then
While rsList.State <> adStateOpen
Set rsList = rsList.NextRecordset
rsList.movenext
wend
end if
This makes it run, however, I only get one record, instead of the 10 that is in the actual form. So, this is not going to work, but wanted to show what I have tried so far.
OK, got it all figured out. below is the code that was used, with a few notes in the code, to show what I did to make it work.
Regardless of what the OP believes this is a duplicate of
ADODB.Recordset error '800a0e78' Operation is not allowed when the object is closed
If we analyse the original code revision (ignoring the hard wrap which will cause an error in VBScript)
You can see that the original issue is the lack of
to stop the closed
ADODB.Recordset
object being returned for the initialINSERT
operation.The subsequent edits the OP makes confuses the issue, before this adding
SET NOCOUNT ON;
would have fix the problem without needing further changes.The next revision is where the confusion begins (again, ignoring the hard wrap which will cause an error in VBScript)
Let's just dissect this part
First the
If
andWhile
loop do the same thing accept theWhile
does it repeatedly until the condition is met, making theIf
completely irrelevant. TheWhile
loop checks for the current state of theADODB.Recordset
which withoutSET NOCOUNT ON;
is returned asadStateClosed
(due to theINSERT
operation). This is fine but by changing theWhile
loop fromto
the condition has been changed and the
While
is no longer checking forrsList.EOF
which would be the case when we are enumerating theADODB.Recordset
object. However, now it is only checking for the.State
ofrsList
which once.NextRecordset
is called will exit the loop as a openADODB.Recordset
object has been returned. Because the condition has been met the loop will only run once calling.MoveNext
once and only returning one record.So to summaries using
initially would have negated this whole scenario but hey "I don't understand the code" apparently.