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!

recursive function

Status
Not open for further replies.

vlitim

Programmer
Sep 2, 2000
393
GB

I am trying to get the code below to work basically a table where all of the entries are linked togethre by a parent column, but I keep getting this error, I kno i have got thi sort of thing working before but just can't see what is going wrong:

ADODB.Recordset error '800a0e78'

Operation is not allowed when the object is closed.



<%
function childCats(id)

If id <> &quot;&quot; Then

SQL=&quot;SELECT id,name,parent FROM category where active=1 AND parent=&quot;&id&&quot; order by name&quot;
set rs=objconn.execute(SQL)
If Not rs.BOF AND not rs.EOF Then
response.write(&quot;<ul>&quot;)
Do While Not rs.EOF
response.write(&quot;<li>&quot;&rs(&quot;name&quot;))
childCats(rs(&quot;id&quot;))
rs.movenext
loop
response.write(&quot;</ul>&quot;)
End If
rs.close
Else
Exit function
End if
End Function


SQL=&quot;SELECT id,name,parent FROM category where active=1 AND parent=-1 order by name&quot;
set cat=objconn.execute(SQL)
Do While Not cat.EOF
%>
<li><%=cat(&quot;name&quot;)%>
<%=childCats(cat(&quot;id&quot;))%>
<%
cat.movenext
loop
cat.close
%>

any help would be much appreciated!
Cheers
Tim
 
Hi vlitim,

This error message is trying to tell you that you have no data connection open.. And if the above posted code is your entire code, then is truely is the case..

You have not provided an open command for objconn

ie:

objconn.open &quot;DSN=DSNNAME;uid=username;pwd=password;&quot;

'make sure you close the connection when done..
objconn.close


Cheers,

Gorkem.
 
forgot to put that in but in the function I have

Dim objConn1
Set ObjConn1 = Server.CreateObject(&quot;ADODB.Connection&quot;)
ObjConn1.open &quot;PROVIDER=SQLOLEDB;Integrated Security=SSPI;DATA SOURCE=******;DATABASE=********&quot;

so I don't understand why I get that error! if I remove :

childCats(rs(&quot;id&quot;))

in the function then I don't get the error, so it seems that the problem lies with the function calling itself!
 
ok my new error is :

ADODB.Recordset error '800a0bcd'

Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.

line 16, which is on the rs.movenext


with this code:
function childCats(catid)

If catid <> &quot;&quot; Then

SQL1=&quot;SELECT id,name,parent FROM category where active=1 AND parent=&quot;&catid&&quot; order by id&quot;
set rs=objconn.execute(SQL1)
If Not rs.BOF Then
response.write(&quot;<ul>&quot;)
rs.MoveFirst
Do While Not rs.EOF
response.write(&quot;<li>&quot;&rs(&quot;id&quot;)&&quot; - &quot;&rs(&quot;name&quot;))
childCats(rs(&quot;id&quot;))
rs.movenext
loop
response.write(&quot;</ul>&quot;)
Else
Exit function
End If
rs.close

Else
Exit function
End If

End Function


SQL=&quot;SELECT id,name,parent FROM category where active=1 AND parent=-1 order by name&quot;
set cat=objconn.execute(SQL)
Do While Not cat.EOF
%>
<li><%=cat(&quot;name&quot;)%>
<%childCats(cat(&quot;id&quot;))%>
<%
cat.movenext
loop
cat.close
%>

anyone got any ideas!?
Cheers, Tim
 
Place active in your requested fields

SQL=&quot;SELECT id,name,parent,active FROM category where active... Saturday 12.00
im6.gif
im2.gif
im2.gif
20.00
im5.gif
im4.gif
im7.gif
3.00am
im8.gif
Sunday [img http
 
the active col is never brought out of the dbase for use so it makes no difference.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top