asp统计表中记录数

2024-12-29 01:01:33
推荐回答(2个)
回答1:

<%
set rs=server.create("adodb.recordset")
rs.open "select count(*) as total from contents",conn,1,1
if not rs.eof then
num=rs(0)
else
num=0
end if
rs.close
set rs=nothing

response.write("contents表的记录总数是:"&num)
%>

回答2:

前提是有conn了
set rs = server.createobject("adodb.recordset")
sql = "select count(*) as total from contents "
rs.open sql,conn,1,1
if not rs.eof then
totalnum = rs("total")
end if
要用总数就用这个totalnum好了