how to count records in ASP classic?

前端 未结 9 1005
陌清茗
陌清茗 2021-01-14 02:50

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?

<%
S         


        
9条回答
  •  情话喂你
    2021-01-14 03:06

    It is possible (but not recommended) to use the RecordCount property on the Recordset object as follows:

    iTotalRecords = rsscroll.RecordCount
    

    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
    

提交回复
热议问题