关于循环问题?

来源:百度知道 编辑:UC知道 时间:2024/05/31 14:40:51
<%BigSql="Select * From DF_Sort2 order by id asc"
set BigRs=server.createobject("adodb.recordset")
BigRs.open BigSql,adocon,1,1
do while not BigRs.eof

SmallSql="Select * From DF_Sort3 Where BigID="&BigRs("ID")&" order by id asc"
Set SmallRs= Server.CreateObject("ADODB.Recordset")
SmallRs.Open SmallSql,adocon,1,1
count = 0
Do While Not SmallRs.Eof%>
subcat[<%=count%>] = new Array("<%= trim(BigRs("BigName"))%>","<%= trim(BigRs("ID"))%>,<%= trim(SmallRs("ID"))%>","<%= trim(BigRs("ID"))%>");
<%count = count + 1
SmallRs.Movenext
Loop
BigRs.movenext
loop
%>
onecount=<%=count%>

循环问题
我想要的是依次循环下来
比如:
subcat[0] = new Array("断路器","1,1","1");

subcat[1] = new Array("断路

<%
BigSql="Select * From DF_Sort2 order by id asc"
set BigRs=server.createobject("adodb.recordset")
BigRs.open BigSql,adocon,1,1

count = 0

while not BigRs.eof
SmallSql="Select * From DF_Sort3 Where BigID="&BigRs("ID")&" order by id asc"
Set SmallRs= Server.CreateObject("ADODB.Recordset")
SmallRs.Open SmallSql,adocon,1,1
While Not SmallRs.Eof%>
subcat[<%=count%>] = new Array("<%= trim(BigRs("BigName"))%>","<%= trim(BigRs("ID"))%>,<%= trim(SmallRs("ID"))%>","<%= trim(BigRs("ID"))%>");
<%count = count + 1
SmallRs.Movenext
wend
BigRs.movenext
end
%>

onecount=<%=count%>

见意你不要用DO WHILE 如果数据库中没有记录的话,会出错的!!
主要是你把count = 0 的位置放错了!!!

Do While Not Smal