asp数据库只显示第一条记录,怎么改能显示前十条
<%@LANGUAGE="VBSCRIPT"CODEPAGE="65001"%><!--#includefile="Connections/conn.asp"--><%D...
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="Connections/conn.asp" -->
<%
Dim dast__MMColParam
dast__MMColParam = "1"
If (Request.QueryString("id") <> "") Then
dast__MMColParam = Request.QueryString("id")
End If
%>
<%
Dim dast
Dim dast_cmd
Dim dast_numRows
Set dast_cmd = Server.CreateObject ("ADODB.Command")
dast_cmd.ActiveConnection = MM_conn_STRING
dast_cmd.CommandText = "SELECT * FROM newinfo WHERE id = ?"
dast_cmd.Prepared = true
dast_cmd.Parameters.Append dast_cmd.CreateParameter("param1", 5, 1, -1, dast__MMColParam) ' adDouble
Set dast = dast_cmd.Execute
dast_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index
Repeat1__numRows = 10
Repeat1__index = 0
dast_numRows = dast_numRows + Repeat1__numRows
%>
<%
Dim Repeat2__numRows
Dim Repeat2__index
Repeat2__numRows = 10
Repeat2__index = 0
dast_numRows = dast_numRows + Repeat2__numRows
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
body {
background-image: url(images/11.jpg);
background-repeat: no-repeat;
}
</style>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<p> </p>
<table width="900" border="1" align="center">
<tr>
<td width="139">菜系</td>
<td width="159">名称</td>
<td width="155">食材</td>
<td width="419">喜爱原因</td>
</tr>
<%
While ((Repeat1__numRows <> 0) AND (NOT dast.EOF))
%>
<tr>
<td><%=(dast.Fields.Item("caixi").Value)%></td>
<td><%=(dast.Fields.Item("mingcheng").Value)%></td>
<td><%=(dast.Fields.Item("shicai").Value)%></td>
<td><%=(dast.Fields.Item("xiaiyuanyin").Value)%></td>
</tr>
<%
Repeat2__index=Repeat2__index+1
Repeat2__numRows=Repeat2__numRows-1
dast.MoveNext()
Wend
%>
</table>
<p> </p>
</form>
</body>
</html>
<%
dast.Close()
Set dast = Nothing
%> 展开
<!--#include file="Connections/conn.asp" -->
<%
Dim dast__MMColParam
dast__MMColParam = "1"
If (Request.QueryString("id") <> "") Then
dast__MMColParam = Request.QueryString("id")
End If
%>
<%
Dim dast
Dim dast_cmd
Dim dast_numRows
Set dast_cmd = Server.CreateObject ("ADODB.Command")
dast_cmd.ActiveConnection = MM_conn_STRING
dast_cmd.CommandText = "SELECT * FROM newinfo WHERE id = ?"
dast_cmd.Prepared = true
dast_cmd.Parameters.Append dast_cmd.CreateParameter("param1", 5, 1, -1, dast__MMColParam) ' adDouble
Set dast = dast_cmd.Execute
dast_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index
Repeat1__numRows = 10
Repeat1__index = 0
dast_numRows = dast_numRows + Repeat1__numRows
%>
<%
Dim Repeat2__numRows
Dim Repeat2__index
Repeat2__numRows = 10
Repeat2__index = 0
dast_numRows = dast_numRows + Repeat2__numRows
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
body {
background-image: url(images/11.jpg);
background-repeat: no-repeat;
}
</style>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<p> </p>
<table width="900" border="1" align="center">
<tr>
<td width="139">菜系</td>
<td width="159">名称</td>
<td width="155">食材</td>
<td width="419">喜爱原因</td>
</tr>
<%
While ((Repeat1__numRows <> 0) AND (NOT dast.EOF))
%>
<tr>
<td><%=(dast.Fields.Item("caixi").Value)%></td>
<td><%=(dast.Fields.Item("mingcheng").Value)%></td>
<td><%=(dast.Fields.Item("shicai").Value)%></td>
<td><%=(dast.Fields.Item("xiaiyuanyin").Value)%></td>
</tr>
<%
Repeat2__index=Repeat2__index+1
Repeat2__numRows=Repeat2__numRows-1
dast.MoveNext()
Wend
%>
</table>
<p> </p>
</form>
</body>
</html>
<%
dast.Close()
Set dast = Nothing
%> 展开
1个回答
展开全部
dast_cmd.CommandText = "SELECT top 10 * FROM newinfo "
'dast_cmd.Prepared = true
'dast_cmd.Parameters.Append dast_cmd.CreateParameter("param1", 5, 1, -1, dast__MMColParam) ' adDouble
找到对应的代码,修改为以上代码既可
追问
非常感谢啊!!顺便问一句刚刚不小心又把记录集弄没了怎么办,重建的话不许用原来的名字dast,换一个别的名字又打不开页面,求帮助
追答
没看懂啥意思?
重建是什么?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询