我不太熟悉ASP经典编程.我只需要在我的网页上运行一个小代码.我如何计算返回查询的记录? %Set rsscroll = Server.CreateObject("ADODB.Recordset")Dim strSQLscroll, rsscrollstrSQLscroll = "SELECT * FROM tblItem
<% 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