• λ我爱Aspx >> C#.Net >> 分栏显示记录集的表格演示,并实现了分页_ASP技巧
  • 分栏显示记录集的表格演示,并实现了分页_ASP技巧

  • :aspxer  Դ:internet  :2007-4-28 23:45:57  ؼ:asp
  • <!-- 本示例演示一个通用的记录集分栏显示,因为有的时候显示产品等要每行显示若干个,而不是每行显示一个。如有有这种分栏显示的表格,直接把下面的代码套进去就行了,本示例是每行显示2个记录,再最下面还显示了分页栏。 -->

    <%

    '打开数据库

    Set conn = Server.CreateObject("ADODB.Connection")

    strconn="Driver={sql server};server=localhost;database=northwind;uid=sa;pwd=sa;"

    conn.Open strconn

    '获取本页地址

    Dim fileName,postion

    fileName = Request.ServerVariables("script_name")

    postion = InstrRev(fileName,"/")+1

    fileName = Mid(fileName,postion)

    '打开记录集www.knowsky.com

    set rs=server.CreateObject("adodb.recordset")

    rs.open "select titleofcourtesy,firstname,photopath from Employees order by employeeid desc",conn,1,1

    %>

    <!-- 产品展示表格 -->

    <table width="90%" height="300" border="0" align="center">

    <%

    if not(rs.bof and rs.eof) then

    pages=4

    rs.pagesize=pages

    if not isempty(Request.QueryString("page")) then

    thispage=clng(Request.QueryString("page"))

    else

    thispage=1

    end if

    rscount=rs.recordcount

    if thispage="" then thispage=1

    if thispage<1 then thispage=1

    if (thispage-1)*pages>rscount then

    if (rscount mod pages)=0 then

    thispage=rscount\pages

    else

    thispage=rscount\pages+1

    end if

    end if

    if(rscount mod pages)=0 then

    allpages=rscount\pages

    else

    allpages=rscount\pages+1

    end if

    rs.absolutepage=thispage

    Ҷƪл˵?
  • һƪ数据分页方法新思路,速度非常快!_ASP技巧
    һƪ用ASP实现长文章用分页符来分页显示_ASP技巧