如何高效统计ASP经典数据库中的特定记录数量?
- 内容介绍
- 相关推荐
本文共计232个文字,预计阅读时间需要1分钟。
我不太熟悉ASP经典编程。我需要在网页上运行一小段代码。我想计算返回查询的记录数。以下是我尝试使用的方法:
aspSet rsscroll=Server.CreateObject(ADODB.Recordset)Dim strSQLscrollrsscroll=SELECT * FROM tblItem
我不太熟悉ASP经典编程.我只需要在我的网页上运行一个小代码.我如何计算返回查询的记录?<% 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属性,如下所示: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
本文共计232个文字,预计阅读时间需要1分钟。
我不太熟悉ASP经典编程。我需要在网页上运行一小段代码。我想计算返回查询的记录数。以下是我尝试使用的方法:
aspSet rsscroll=Server.CreateObject(ADODB.Recordset)Dim strSQLscrollrsscroll=SELECT * FROM tblItem
我不太熟悉ASP经典编程.我只需要在我的网页上运行一个小代码.我如何计算返回查询的记录?<% 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属性,如下所示: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

