how to count records in ASP classic?

前端 未结 9 992
陌清茗
陌清茗 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:16

    Get in the habbit of storing returned data in arrays. This is amazingly faster to iterate than using an open record set. Also, specify the fields to select when doing this as you have to explicitly reference the array index.

    <%
    Set rsscroll = Server.CreateObject("ADODB.Recordset")
    Dim strSQLscroll, rsscroll
    Dim arrCommon
    
    'Open recordset, copy data to array
    strSQLscroll = "SELECT field1, field2, field3 FROM tblItems where expiration_date > getdate() order by expiration_date desc;"
    rsscroll.open strSQLscroll,oConn
        arrCommon = rsscroll.getRows()
    rsscroll.close
    
    'Get the total records in this array
    response.write ubound(arrCommon, 2);
    
    'Loop...
    for i = 0 to ubound(arrCommon, 2)
    
        ' This prints field 3
        response.write arrCommon(2, i)
    
    next
    %>
    

提交回复
热议问题