ASP递归的SUB为何使用ACCES能用,SQL server 就错误呢?
sub allcategory(ID) 'ID为传递来的值set rs=server.createobject("adodb.recordset")
strsql="select categoryid,ParentID from [category] where categoryid="&ID
rs.open strsql,conn,1,1
if not(rs.bof and rs.eof) then
allclassID=allclassID&rs(0)&","
allcategory(rs("ParentID")) '调用fl()函数,实现递归
end if
end sub
提示 错误 '80020009' ......行 50
行 50 的语句是 :strsql="select categoryid,ParentID from [category] where categoryid="&ID
------------------------------------------------------------------------------------------------------------------------------------------------------------
以下是同一个数据表,同样是SQL数据库中使用的 递归SUB 确能正确显示( 这是什么原因做成的呢)
sub sort(selec)
sql="select * from category where ParentID = "&selec&" order by categoryorder"
Set Rs1=Conn.Execute(sql)
if rs1.eof or rs1.bof then
noclass=1
else
rs1.movefirst
firstid=rs1("categoryid")
do while not rs1.eof
if selec=0 then
%>
<option value="<%=int(rs1("categoryid"))%>"><%=rs1("category")%></option>
<%
else
%>
<option value="<%=int(rs1("categoryid"))%>"><%=string(ii*2," ")%><%=rs1("category")%></option>
<%
end if
ii=ii+1
sort rs1("categoryid")
ii=ii-1
rs1.movenext
loop
rs1.close
Set Rs1 = Nothing
end if
end sub