<% if rs.eof then response.write("数据库中没有信息!") end if %> <% do while not rs.eof%> <tr> <td><%rs=""&id&""%></td> <td><%rs=""&username&""%></td> <td><%rs=""&userpassword&""%></td> <td><%rs=""&hit&""%></td> </tr> <% rs.next loop %>
<% if rs.eof then response.write("数据库中没有信息!") end if %> <% do while not rs.eof%> <tr> <td><%rs=""&id&""%></td> <td><%rs=""&username&""%></td> <td><%rs=""&userpassword&""%></td> <td><%rs=""&hit&""%></td> </tr> <% rs.next loop %>
</table> </body> </html> 大家帮我看看有什么错误
set rs=server.CreateObject("adodb.recordset") 你的rs没有指定ActiveConnection
loop
do while not rs.eof
response.write "<tr><td>" & rs(0) & "</td></tr>"
loop
response.write "</table>"
plus:好象你贴错了地方了哦;)如果你用的是asp.net那就根本不需要循环表格,直接用DataGrid等控件就可。
<!--#include file="conn.asp"-->
<%set rs=server.CreateObject("adodb.recordset")(提示这个地方有错误 )
sql="select * from user "
%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head><body>
<table width="75%" border="1">
<tr>
<td>id</td>
<td>username</td>
<td>userpassword</td>
<td>hit</td>
</tr>
<%
if rs.eof then
response.write("数据库中没有信息!")
end if
%>
<%
do while not rs.eof%>
<tr>
<td><%rs=""&id&""%></td>
<td><%rs=""&username&""%></td>
<td><%rs=""&userpassword&""%></td>
<td><%rs=""&hit&""%></td>
</tr>
<%
rs.next
loop
%>
</table>
</body>
</html>
大家帮我看看有什么错误的地方
<!--#include file="conn.asp"-->
<%set rs=server.CreateObject("adodb.recordset")(提示这个地方有错误)
sql="select * from user "
%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head><body>
<table width="75%" border="1">
<tr>
<td>id</td>
<td>username</td>
<td>userpassword</td>
<td>hit</td>
</tr>
<%
if rs.eof then
response.write("数据库中没有信息!")
end if
%>
<%
do while not rs.eof%>
<tr>
<td><%rs=""&id&""%></td>
<td><%rs=""&username&""%></td>
<td><%rs=""&userpassword&""%></td>
<td><%rs=""&hit&""%></td>
</tr>
<%
rs.next
loop
%>
</table>
</body>
</html>
大家帮我看看有什么错误
你的rs没有指定ActiveConnection
如果有错误只能说明你的服务器上没有提供数据访问组件,可能你需要联系管理员添加,好象是DAO2.0以上
2.需要打开数据库连接才能读取数据:rs.open sql,conn,其中conn是定义在你的conn.asp中的数据库连接对象。
3.<%rs=""&id&""%>是不对的.这样写:<%=rs("id")%>
4.rs.next也不对.这样写:rs.MoveNext
5.最后最好要关闭数据库连接set conn=nothing