我想用asp do while 语句 循环输出sql 数据库中的字段内容 在子do while 里 还要输出另外一个数据表的内容
<%Dimzsql,csql,zRs,cRsIfChannelID=113Thencsql="SelectClassID,ID,FolderName,TS,TN,TJfr...
<%
Dim zsql,csql,zRs,cRs
If ChannelID=113 Then
csql ="Select ClassID,ID,FolderName,TS,TN,TJ from KS_Class where TN='20119065171248'"
Set cRs = Conn.Execute(csql)
zsql ="Select KS_Fname,ID,KS_CID from KS_Form_zcfile where ID=" & cRS("ID") & "order by KS_CID"
Set zRs = Conn.Execute(zsql)
Do While not cRs.eof
response.write "<li>" & cRs("FolderName") & "</li>"
'response.write "--" & cRS("ID")
'response.write "<br />"
'response.write zRs("KS_Fname")
'Do until zRs.eof
' response.write zRs("KS_Fname")
' response.write " "
' zRs.movenext
'Loop
'response.write "<br />"
cRS.movenext
Loop
End If
%>
现在我有两个数据表 ,a ,b a--用于存放栏目 b-用于存放栏目ID对应的 内容.
现在我想要实现的效果是:
栏目1输出(a表栏目表)
栏目1对应内容1(b表)
栏目1对应内容2(b表)
栏目2输出(a表栏目表)
栏目2对应内容1(b表)
.......直到全部输出...
我上面的代码就不知道为什只执行了第一个do while 而第二个do while 就没有执行 展开
Dim zsql,csql,zRs,cRs
If ChannelID=113 Then
csql ="Select ClassID,ID,FolderName,TS,TN,TJ from KS_Class where TN='20119065171248'"
Set cRs = Conn.Execute(csql)
zsql ="Select KS_Fname,ID,KS_CID from KS_Form_zcfile where ID=" & cRS("ID") & "order by KS_CID"
Set zRs = Conn.Execute(zsql)
Do While not cRs.eof
response.write "<li>" & cRs("FolderName") & "</li>"
'response.write "--" & cRS("ID")
'response.write "<br />"
'response.write zRs("KS_Fname")
'Do until zRs.eof
' response.write zRs("KS_Fname")
' response.write " "
' zRs.movenext
'Loop
'response.write "<br />"
cRS.movenext
Loop
End If
%>
现在我有两个数据表 ,a ,b a--用于存放栏目 b-用于存放栏目ID对应的 内容.
现在我想要实现的效果是:
栏目1输出(a表栏目表)
栏目1对应内容1(b表)
栏目1对应内容2(b表)
栏目2输出(a表栏目表)
栏目2对应内容1(b表)
.......直到全部输出...
我上面的代码就不知道为什只执行了第一个do while 而第二个do while 就没有执行 展开
展开全部
因为你没有嵌套使用,试试看下面这样
<%
Dim zsql,csql,zRs,cRs
If ChannelID=113 Then
csql ="Select ClassID,ID,FolderName,TS,TN,TJ from KS_Class where TN='20119065171248'"
Set cRs = Conn.Execute(csql)
Do While not cRs.eof
response.write "<li>" & cRs("FolderName") & "</li>"
zsql ="Select KS_Fname,ID,KS_CID from KS_Form_zcfile where ID=" & cRS("ID") & "order by KS_CID"
Set zRs = Conn.Execute(zsql)
Do While not zRs.eof
response.write "<li> "&zRs("KS_Fname")&"</li>
zRs.movenext
loop
zRs.close
cRS.movenext
Loop
cRs.close
End If
%>
<%
Dim zsql,csql,zRs,cRs
If ChannelID=113 Then
csql ="Select ClassID,ID,FolderName,TS,TN,TJ from KS_Class where TN='20119065171248'"
Set cRs = Conn.Execute(csql)
Do While not cRs.eof
response.write "<li>" & cRs("FolderName") & "</li>"
zsql ="Select KS_Fname,ID,KS_CID from KS_Form_zcfile where ID=" & cRS("ID") & "order by KS_CID"
Set zRs = Conn.Execute(zsql)
Do While not zRs.eof
response.write "<li> "&zRs("KS_Fname")&"</li>
zRs.movenext
loop
zRs.close
cRS.movenext
Loop
cRs.close
End If
%>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询