ASP中嵌套循环查询求助~在线等!~
<%
set rs1 = server.createobject("adodb.recordset")
sql1 = "select * from ArcFile where num='0001' and t='h'"
rs1.open sql1,conn,1,1
dim wj
do while not rs1.eof
set rs2 = server.createobject("adodb.recordset")
sql2 = "select * from ArcWord where wjm='"& rs1("wj") & "'"
rs2.open sql2,conn,1,1
do while not rs2.eof
response.Write(rs1("wj"))
response.Write(rs2("wjm"))
rs2.movenext
loop
call close_rs2
rs1.movenext
loop
call close_rs1
%>
------解决方案--------------------你的DIM定义貌似没用上嘛。
你想要是应该是这样的吧
<%
dim wj1,wj2
set rs1 = server.createobject("adodb.recordset")
sql1 = "select * from ArcFile where num='0001' and t='h'"
rs1.open sql1,conn,1,1
do while not rs1.eof
wj1=rs1("wj")
set rs2 = server.createobject("adodb.recordset")
sql2 = "select * from ArcWord where wjm='"& wj1 &"'"
rs2.open sql2,conn,1,1
do while not rs2.eof
wj2=rs2("wjm")
'你是要这这循环输出吧
response.Write(wj1)
response.Write(wjm)
'循环输出结束
rs2.movenext
loop
call close_rs2
rs1.movenext
loop
call close_rs1
%>