主题:用循环,但显示数据库有漏记录的现象
请教,代码:
<%set rs=server.CreateObject("adodb.recordset")
if lbdm=14 then
sql="select * from zxml2000 where yigaob<>0 or yigaox<>0 order by id asc"
elseif lbdm=23 then
sql="select * from zxml2000 where erwanb<>0 or erwanx<>0 order by id asc"
elseif lbdm=12 then
sql="select * from zxml2000 where yichub<>0 or yichux<>0 order by id asc"
elseif lbdm=22 then
sql="select * from zxml2000 where erchub<>0 or erchux<>0 order by id asc"
elseif lbdm=32 then
sql="select * from zxml2000 where sanchub<>0 or sanchux<>0 order by id asc"
end if
rs.open sql,conn,1,1
if not rs.eof and not rs.bof then
i=1
while not rs.eof and not rs.bof
if lbdm=14 then
bp=rs("yiwanb")
xp=rs("yiwanx")
elseif lbdm=23 then
bp=rs("erwanb")
xp=rs("erwanx")
elseif lbdm=12 then
bp=rs("yichub")
xp=rs("yichux")
elseif lbdm=22 then
bp=rs("erchub")
xp=rs("erchux")
elseif lbdm=32 then
bp=rs("sanchub")
xp=rs("sanchux")
end if
%>
<tr>
<th scope="col"> <%=rs("yiqibh")%></th>
<th scope="col"> <%=rs("mingcheng")%></th>
<th scope="col"> <%=rs("guigexh")%></th>
<th scope="col"> <%=rs("danwei")%></th>
<th scope="col"> <%=rs("cankaodj")%></th>
<th scope="col">
<%response.write(bp)%>
</th>
<th scope="col">
<%response.write(xp)%>
</th>
<th scope="col"> </th>
<th scope="col"> <%=rs("kedaiyyq")%></th>
<th scope="col"> <%=rs("beizhu")%></th>
<th scope="col"> <%=rs("kemu")%></th>
</tr>
<%rs.movenext
i=i+1
wend
end if
%>共<%response.Write(i)%>条
这里显示出来的i的记录数是908条,与access里实际存在的记录1315条相差很多。我检查了一下,漏掉的记录数没有规律,如从头开始分别是第7、11、10、11、19、48条。漏掉的记录也没有相同的特征。
谢谢指教。
<%set rs=server.CreateObject("adodb.recordset")
if lbdm=14 then
sql="select * from zxml2000 where yigaob<>0 or yigaox<>0 order by id asc"
elseif lbdm=23 then
sql="select * from zxml2000 where erwanb<>0 or erwanx<>0 order by id asc"
elseif lbdm=12 then
sql="select * from zxml2000 where yichub<>0 or yichux<>0 order by id asc"
elseif lbdm=22 then
sql="select * from zxml2000 where erchub<>0 or erchux<>0 order by id asc"
elseif lbdm=32 then
sql="select * from zxml2000 where sanchub<>0 or sanchux<>0 order by id asc"
end if
rs.open sql,conn,1,1
if not rs.eof and not rs.bof then
i=1
while not rs.eof and not rs.bof
if lbdm=14 then
bp=rs("yiwanb")
xp=rs("yiwanx")
elseif lbdm=23 then
bp=rs("erwanb")
xp=rs("erwanx")
elseif lbdm=12 then
bp=rs("yichub")
xp=rs("yichux")
elseif lbdm=22 then
bp=rs("erchub")
xp=rs("erchux")
elseif lbdm=32 then
bp=rs("sanchub")
xp=rs("sanchux")
end if
%>
<tr>
<th scope="col"> <%=rs("yiqibh")%></th>
<th scope="col"> <%=rs("mingcheng")%></th>
<th scope="col"> <%=rs("guigexh")%></th>
<th scope="col"> <%=rs("danwei")%></th>
<th scope="col"> <%=rs("cankaodj")%></th>
<th scope="col">
<%response.write(bp)%>
</th>
<th scope="col">
<%response.write(xp)%>
</th>
<th scope="col"> </th>
<th scope="col"> <%=rs("kedaiyyq")%></th>
<th scope="col"> <%=rs("beizhu")%></th>
<th scope="col"> <%=rs("kemu")%></th>
</tr>
<%rs.movenext
i=i+1
wend
end if
%>共<%response.Write(i)%>条
这里显示出来的i的记录数是908条,与access里实际存在的记录1315条相差很多。我检查了一下,漏掉的记录数没有规律,如从头开始分别是第7、11、10、11、19、48条。漏掉的记录也没有相同的特征。
谢谢指教。