为什么我的查询只显示数据库第一个纪录?
代码如下: <html>
<body BGCOLOR= "#ffccff ">
<center>
<form method= "post " action= "select.asp " ID= "Form1 ">
姓名: <input type= "text " name= "name ">
<input type= "submit " value= "select ">
<% dim sql,name,rs_select
name=trim(request.Form( "name "))
set conn=server.CreateObject( "ADODB.Connection ")
set rs=server.CreateObject( "ADODB.RecordSet ")
conn.Open ( "Driver={SQL Server};server=192.168.1.180;database=test;UID=sa;PWD=sa; ")
if name= " " then
response.Write " <br> 请填写查询关键字 "
else
sql= "select * from details where name like ' "&name& "% ' "
set rs_select=conn.Execute(sql)
if rs_select.EOF then
response.write( " <font color= 'red '> 对不起,找不到该姓名! </font> ")
response.end()
else
%>
<table border= "1 " ID= "Table1 ">
<tr>
<td> 编号 </td>
<td> 姓名 </td>
<td> 性别 </td>
<td> 出生日期 </td>
<td> 民族 </td>
<td> 备注 </td>
</tr>
<%
if Not rs_select.EOF then
Response.Write " <TR> "
for i=0 to rs_select.fields.count-1
Response.Write " <TD> "&rs_select(i).value& " </TD> "
next
rs_select.MoveNext
Response.Write " </TR> "
End if
end if
end if
%>
</table>
</form>
</center>
</body>
</html>
哪位高手指点一下啊!
------解决方案--------------------for i=0 to rs_select.fields.count-1
这个不对吧,,rs_select.recordcount,用这个试试
另外建议把for循环改成do while循环
do while not rs_select.eof
<!--显示数据-->
rs_select.movenext
loop
do while 可以避免游标问题,
我不是高手,
--