我对 ASP classic 编程不太熟悉。我只需要一小段代码即可在我的网页上运行。如何统计返回查询的记录数?
<%
Set rsscroll = Server.CreateObject("ADODB.Recordset")
Dim strSQLscroll, rsscroll
strSQLscroll = "SELECT * FROM tblItems where expiration_date > getdate() order by expiration_date desc;"
rsscroll.open strSQLscroll,oConn
%>
thanks,
可以(但不推荐)在 Recordset 对象上使用 RecordCount 属性,如下所示:
iTotalRecords = rsscroll.RecordCount
如果您的表非常大,则可能需要很长时间才能运行。我会运行一个单独的 SQL 查询来获取总记录
SQL = "SELECT COUNT(*) AS TotalRecords FROM tblItems WHERE expiration_date > getdate() "
set rsRecordCount = conn.Execute(SQL)
if not rsRecordCount.Eof then
iTotalRecords = rsRecordCount.Fields("TotalRecords")
else
iTotalRecords = 0
end if
rsRecordCount.Close
set rsRecordCount = nothing
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)