求解答asp中rs循环问题!谢谢!

来源:百度知道 编辑:UC知道 时间:2024/06/25 05:06:03
请问asp中,怎么实现rs循环中内嵌一个rs循环阿?
比如我有2个表,一个大类别type表,一个子类别subtype表,我想实现大类别循环中内嵌一个子类别循环,不知道可以不?
我写了一段代码不知道哪里错了,请好心人帮帮忙,我是新手,谢谢~~代码如下:
--------------------------------------------
<table border="0" cellpadding="0" style="border-collapse: collapse" width="800" id="table4">
<tr>
<td colspan="2"><font size="2" color="#008080">
[所有类别列表]</font></td>
</tr>
<%
Set rs1 = Server.CreateObject("ADODB.Recordset")
sql="select * from type"
rs1.open sql,conn,1,1
do while not rs1.eof
%>
<tr>
<td width="200"><%=rs1("type_name")%></td>
<td width="600">
<%
dim id
id=rs1("type_id")

response.write("&rs2("subtype_name")&")
为什么不直接写response.write(rs2("subtype_name")) ?
还有这句strsql="select * from subtype where type_id = id "
应该改成 strsql="select * from subtype where type_id = '"&id&"' "
如果id是数字的话可以
strsql="select * from subtype where type_id = "&id

每一次都set一个rs2 累点 用个数组保存不行吗?我倒是没用过数组,不过asp肯定支持至少一维的吧?
没怎么仔细看 就挑出来这两个毛病