如何计算 ASP 经典中的记录? [英] how to count records in ASP classic?
本文介绍了如何计算 ASP 经典中的记录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我对 ASP 经典编程不是很熟悉.我只需要一个小代码就可以在我的网页上运行.返回查询的记录如何统计?
I'm not quite familiar with programming ASP classic. I just need a small code to run on my webpage. How do i count the record of the returned query?
<%
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
%>
谢谢,
推荐答案
可以(但不推荐)在 Recordset 对象上使用 RecordCount 属性,如下所示:
It is possible (but not recommended) to use the RecordCount property on the Recordset object as follows:
iTotalRecords = rsscroll.RecordCount
如果您的表非常大,这可能需要很长时间才能运行.我会改为运行单独的 SQL 查询来获取总记录
If your table is really large, this can take a long time to run. I would instead run a separate SQL query to get the total records
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
这篇关于如何计算 ASP 经典中的记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文