如何计算在ASP经典的记录? [英] how to count records in ASP classic?
本文介绍了如何计算在ASP经典的记录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我不是很熟悉编程ASP经典。我只需要一个小code在我的网页上运行。我如何计算返回查询的记录?
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
%>
感谢,
推荐答案
这是可能的(但不推荐)使用RecordCount属性Recordset对象上进行如下:
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屋!
查看全文