asp 嵌套循环 20
fori=0tokhRS.RecordCountifkhRS(i)<>""thenSetrst3=objDB.CreateRecordsetB(""&phsql&"","...
for i=0 to khRS.RecordCount
if khRS(i) <> "" then
Set rst3=objDB.CreateRecordsetB("" & phsql & "","<%=Application("clientStrHrConn1")%>")
if rst3.RecordCount>0 then
do while not rst3.eof
RowBuf(0) = khRS("MA001")
RowBuf(1) = khRS("MA002")
RowBuf(2) = rst3("MB001")
RowBuf(3) = rst3("MB002")
RowBuf(4) = rst3("MB149")
RowBuf(5) = rst3("MB072")
RowBuf(6) = "N"
RowBuf(7) = "Y"
RowBuf(8) = document.all("bjsq016").value
RowBuf(9) = MID(document.all("bjsq011").value,1,4)+MID(document.all("bjsq011").value,6,2)+MID(document.all("bjsq011").value,9,10)
RowBuf(10) = MID(document.all("bjsq012").value,1,4)+MID(document.all("bjsq012").value,6,2)+MID(document.all("bjsq012").value,9,10)
grid1.AddItem RowBuf
rst3.movenext
loop
end if
end if
next
khRS中结果集为两行数据:A
C
phRS中结果集为两行数据:B
D
想实现的效果是:
A C
A D
B C
B D
循环的结果却是 集合中未找到项目,哪位大虾帮帮忙啊! 就这一个问题 就能完成任务了 小弟感激不尽!
是asp代码 不是VBScript
现在的效果是:
A C
A D
A C
A D
A C
A D 展开
if khRS(i) <> "" then
Set rst3=objDB.CreateRecordsetB("" & phsql & "","<%=Application("clientStrHrConn1")%>")
if rst3.RecordCount>0 then
do while not rst3.eof
RowBuf(0) = khRS("MA001")
RowBuf(1) = khRS("MA002")
RowBuf(2) = rst3("MB001")
RowBuf(3) = rst3("MB002")
RowBuf(4) = rst3("MB149")
RowBuf(5) = rst3("MB072")
RowBuf(6) = "N"
RowBuf(7) = "Y"
RowBuf(8) = document.all("bjsq016").value
RowBuf(9) = MID(document.all("bjsq011").value,1,4)+MID(document.all("bjsq011").value,6,2)+MID(document.all("bjsq011").value,9,10)
RowBuf(10) = MID(document.all("bjsq012").value,1,4)+MID(document.all("bjsq012").value,6,2)+MID(document.all("bjsq012").value,9,10)
grid1.AddItem RowBuf
rst3.movenext
loop
end if
end if
next
khRS中结果集为两行数据:A
C
phRS中结果集为两行数据:B
D
想实现的效果是:
A C
A D
B C
B D
循环的结果却是 集合中未找到项目,哪位大虾帮帮忙啊! 就这一个问题 就能完成任务了 小弟感激不尽!
是asp代码 不是VBScript
现在的效果是:
A C
A D
A C
A D
A C
A D 展开
2个回答
展开全部
问题就出现在这段代码上了:
RowBuf(0) = khRS("MA001")
RowBuf(1) = khRS("MA002")
RowBuf(2) = rst3("MB001")
RowBuf(3) = rst3("MB002")
RowBuf(4) = rst3("MB149")
RowBuf(5) = rst3("MB072")
要确定你数据库的列名和你写的:MA001,MA002,MB001,MB002,MB149,MB072是一样的,你得错误提示是那一行?
RowBuf(0) = khRS("MA001")
RowBuf(1) = khRS("MA002")
RowBuf(2) = rst3("MB001")
RowBuf(3) = rst3("MB002")
RowBuf(4) = rst3("MB149")
RowBuf(5) = rst3("MB072")
要确定你数据库的列名和你写的:MA001,MA002,MB001,MB002,MB149,MB072是一样的,你得错误提示是那一行?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询