哪位大哥帮我看一下这段代码有什么问题?谢谢

来源:百度知道 编辑:UC知道 时间:2024/05/26 05:11:38
代码如下:
<form name="form1" method="post" action="untitled3.asp">
<p>
<input type="text" name="xingming">
<input type="submit" name="Submit" value="提交">
</p>
<p> </p>
</form>
<!--#include file=conn.asp-->
<%
dim xingming,rs
xingming=request.form("xingming")
set rs=conn.execute("select * from 同学录 where 姓名='"& xingming &"'")
%>
<%
for i=1 to rs.fields.count-2
next
%>
<%=rs(i).name%>:<%=rs(i)%><br>
<%
do while not rs.eof
rs.movenext
loop
%>
这代码是显示根据提交的表单上的姓名来显示对应表中相关信息,但结果只显示了表中倒数第一行的信息,哪位大哥知道的指教一下.谢谢
ADODB.Recordset (0x800A0CC1)
Item cannot be found in the collection corresponding to the requested name or ordinal.
/web/alumn

<%
do while not rs.eof
response.write rs("姓名")&"<br>"
rs.movenext
loop
%>

那个错是表示数据库中不存在此列名,因为你的列名是“姓名”,不是"name",niusoft那样是可以的,把name换成姓名就OK了,wend是一个关键字,VBS的几种循环之一,格式如下

while 条件表达式
循环体
wend
在条件表达式为真时执行循环体,是
do while loop的简写方式

<%
for i=1 to rs.fields.count-2
next
%>
<%=rs(i).name%>:<%=rs(i)%><br>
<%
这是遍历这个表中的所有的列名,并不是显示其中的记录
do while not rs.eof
rs.movenext
loop
应该改成
while rs.eof = false
response.write(rs.fields("name").value + "<br>")
rs.movenext
wend

把下面的改改:
<%
for i=1 to rs.fields.count-2
next
%>
<%=rs(i).name%>:<%=rs(i)%><br>
<%
do while not rs.eof
rs.movenext
loop
%>
改成这样:
<%
do while not rs.eof
for i=1 to rs.fi