在ASP中提问,也许是别人认为很简单,没有什么回答,可我弄了几天了

解决方案 »

  1.   

    adodb.recordset记录集的reccount有时是无效的。
    最好的是用sql="select count(*) as recoun from yourtable"
    或者记录集循环得到记录数
      

  2.   

    Rs.Open SQL,cn,1,3
    改成
    Rs.Open SQL,cn,3,3
    试一下
      

  3.   

    <%
    set rs1 = Server.CreateObject("ADODB.Recordset")
    rs1.ActiveConnection = MM_conn_STRING
    rs1.Source = "SELECT TITLENO, TITLE, CURRENTTIME, USERNAMENO, USERNAME, FORUMNO, STATS, NUM, TIMES, LASTMAN, LASTDATE, LASTNO FROM ZDWY.MESSAGE WHERE FORUMNO = '"&Request("FORUMNO")&"' ORDER BY LASTDATE DESC"
    rs1.CursorType = 0
    rs1.CursorLocation = 3
    rs1.LockType = 3
    rs1.Open()
    %>
    <%
      sub showpage(rs1,pageno)
        
    rs1.absolutepage=pageno
    for n=1 to rs1.pagesize
             response.write "<tr>"
             response.write "<TD align=middle width=30 ><A href='javascript:O1(62)'><IMG src='images/locktop.gif' width=15 border=0 height='15'></A></TD>" 
             response.write "<TD align=left width='369'>&nbsp;<A href='javascript:O2(62)'><IMG height=13 src='images/04.gif' width=13"
                 response.write "align=absMiddle border=0></A>&nbsp;<SPAN id=forum>" 
                 response.write "<A title="&rs1("title")&"nbsp;&#10;发布时间:"&rs1("currenttime")&"nbsp; href='title.asp?forumno="&request("forumno")&"&forumname="&request("forumname")&"&titleno="&rs1("titleno")&"'>"&rs1("title")&"</A> </SPAN></TD>"
     response.write "<TD align=middle width=78 >" 
                 response.write "<A href='data.asp?usernameno="&rs1("usernameno")&"'>"&rs1("username")&"</A></TD>"
     response.write "<TD align=middle width=30 ><FONT color=#333333>"&rs1("num")&"</FONT></TD>"
     response.write "<TD align=middle width=30 ><FONT color=#333333>"&rs1("times")&"</FONT></TD>"
     response.write "<TD align=middle width=120 >" 
                                if isnull(rs1("lastdate")) then
                           response.write rs1("currenttime")
                            else
                           response.write rs1("lastdate")
                        end if
     response.write "</TD>"
     response.write "<TD width=68 >" 
                                if isnull(rs1("lastman")) then
                      response.write  "......"
                    else
                      response.write "<A href='data.asp?usernameno="&rs1("lastno")&"'>"&rs1("lastman")&"</a>"  
                    end if
     response.write "</TD></TR>"
     rs1.movenext()
     if rs1.eof then exit for  
    next  
       end sub
    %>
    <TABLE borderColor=#F2FBF1 cellSpacing=0 width=755 border=1>
        <TBODY> 
        <% 
      rs1.PageSize=20
       pageno=clng(request("pageno"))
       if pageno<1 then pageno=1
       if pageno>rs1.pagecount then pageno=rs1.pagecount
       showpage rs1,pageno
        %>
        </TBODY> 
      </TABLE>
      

  4.   

    rs1.CursorLocation = 3
    这句比较重要分页,记录数也可统计出来的还有问题吗?
      

  5.   

    的确这样
    asp中,对oracle是很奇怪的,可能是oracle不支持
    rs.RECORDCOUNT无效
    rs.PAGECOUNT有效
    所以可以通过count(*)取得总记录数,代替rs.RECORDCOUNT
      

  6.   

    set CursorLocation to Local then you can use recordcount. otherwise it doesn't work.