如何查出数据库中的记录总数?比如数据库有10条信息,只要记录总数10。

lvyin 2002-06-21 11:48:23
如何查出数据库中的记录总数?比如数据库中有10条信息,只要记录总数10。
...全文
79 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
quchanghai 2002-06-21
  • 打赏
  • 举报
回复
<script>
function gg()
{
if (isNaN(document.mm.mypage.value)&&document.mm.mypage.value!="")
{alert("页码为非数值数据!!!");
return(false);
}
return(true);

}

</script>
<%
set c1=server.createobject("adodb.connection")
p1="provider=microsoft.jet.OLEDB.4.0;"
path="data source="&server.mappath("huoyun.mdb")
c1.open p1&path
mypagesize=18
mypage=request.querystring("mypage")
num=request.querystring("num")
if num="" then
num=10
end if
num=cint(num)

if mypage="" or mypage<=0 then
mypage=1
end if
if cint(mypage)>=num then
mypage=num
end if

sheng=request.form("sheng")
set rs=server.createobject("adodb.recordset")
sql="select * from zhuyao where 'a'='a' order by -id "
rs.cursorlocation=3
rs.open sql,c1
rs.pagesize=mypagesize
num=rs.pagecount
if cint(mypage)<=num then
rs.absolutepage=mypage
end if
%>



<html>
<head>
<meta http-equiv='content-type' content='text/html; charset=gb2312'>
<meta http-equiv=refresh content='20;url=f1.asp?num=<%=num%>&mypage=<%=mypage%>'>
<style type="TEXT/CSS">
<!--
body,table {color:#000000;font-family: 宋体_GB2312; font-size: 9pt; line-height: 12pt}
A:link {text-decoration: none; font-family: "宋体"; font-size: 9pt; line-height: 12pt; color: #FFFFFF}
A:visited {text-decoration: none; font-family: "宋体"; font-size: 9pt; line-height: 12pt; color: #FFFFFF}
A:active {text-decoration: underline; color: #E00000; font-family: "宋体"; font-size: 9pt; line-height: 12pt}
A:hover {text-decoration: none; font-family: "宋体"; font-size: 9pt; line-height: 12pt; color: #FFFFFF}
-->
</style>
<title>好运信息网欢迎您!</title>
<base target="_self">
</head>
<body text="#660099" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="775" border="0" align="center" cellspacing="1" cellpadding="1" bgcolor="#000000" height="36">
<tr bgcolor="#666666">
<td height="22" width="384"><font color="#FFFFFF" size="3"><b>今天是<%=now%>,发布的信息如下:</b></font></td>
<td height="22" width="384">
<div align="right"> <font color="#FFFFFF"></font><font color="#FFFFFF"> </font><a href="f1.asp" target="_self"><font color="#FFFF00" size="3">手动刷新</font></a>  <a href="cxmain.asp" target="_blank"><font color="#FFFF00" size="3">查询</font></a><font color="#FFFFFF"> 
</font><a href="minglu.asp" target="_blank"><font color="#FFFF00" size="3">配货站名录</font></a></div>
</td>
</tr>

<%
bb=0
do while not rs.eof and bb<mypagesize
%>


<%
dim a
if rs("leixing")="车" then
a="#008000"
else
a="#0000FF"
end if
%>

<tr bgcolor="#CCCCCC">
<td height="18" width="769" colspan="2"> <img src="lastpost.gif" width="10" height="9"><a href="#" onClick=window.open("xiangxi.asp?id=<%=rs("id")%>","market","menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=0,width=400,top=5,left=205,height=320") </a><font color="<%=a%>" size="3"><b><%=rs("duixiang")%></b></font></a><font size="3">站</font>
<b> <font color="<%=a%>" size="3"><%=rs("leixing")%> </font> </b> <b><font color="<%=a%>" size="3"><%=rs("sheng")%>
<%=rs("shi")%></font></b> <font size="3">到 <font color="<%=a%>" size="3"><b><%=rs("sheng1")%><%=rs("shi1")%></b></font> 车长</font><b><font color="<%=a%>" size="3"><%=rs("chechang")%></font></b>
<b><font color="<%=a%>" size="3"><%=rs("dunwei")%>吨</b></font> <font size="3">说明</font><b>
<font color="<%=a%>" size="3"> <%=rs("neirong")%></font></b>  <font color="<%=a%>" size="2">(<%=rs("sj")%>)</font>
</td>
</tr>
<%
rs.movenext
bb=bb+1
loop

%>

<form method="get" action="f1.asp" name="mm" onsubmit="return gg()" >
<td align=right width="754" height="1"> <font color="#FFFFFF"><%=mypage%>/<%=num%>  第 <input type="text" name="mypage" size="3">
页   <% if mypage-1>=1 then %> <a href="f1.asp?num=<%=num%>&mypage=<%=mypage-1%>" >[上一页]</a>
<% end if %>
<% if cint(mypage)<num then %>
<a href="f1.asp?num=<%=num%>&mypage=<%=mypage+1%>" >[下一页]</a>
</font>
<% end if %>
</form>
</table>
<p>

-------------------------------------------------------
以上是我的代码,请指点
ghumorst 2002-06-21
  • 打赏
  • 举报
回复
第一位是正确的呀,,,你不会就把那段代码原摸原样的就这么搬过去用了吧。其中cn.Open strcon中的strcom是要根据你自己的实际数据库连接方式定义的字符串。。。你是不是这里错了。
quchanghai 2002-06-21
  • 打赏
  • 举报
回复
以上的我都试过了,但是没好用,我是个笨鸟,请高手写的详细些,好吗?谢谢!
quchanghai 2002-06-21
  • 打赏
  • 举报
回复
以上的我都试过了,没好用,请高手写的详细些好吗?谢谢
chulian 2002-06-21
  • 打赏
  • 举报
回复
rs.open "select count(*) as aa from 表",cn

rs("aa")既是所求
blues-star 2002-06-21
  • 打赏
  • 举报
回复
ORACLE

select * from table where rownum < 10
liyunsong2000 2002-06-21
  • 打赏
  • 举报
回复
set cn=server.CreateObject("Adodb.connection")
cn.Open strcon
set rst21=server.CreateObject("adodb.recordset")
rst21.CursorLocation=3
rst21.Open "SELECT routegroupname FROM RouteGroupTab",cn
kk=rst21.recordcount
response.write kk
chulian 2002-06-21
  • 打赏
  • 举报
回复
第几行报错?报什么错?

28,408

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧