Easiest Code for Database Paging

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default Easiest Code for Database Paging

    Can anyone help me find a code for Database Paging?

    I have seen some of it but its very hard for me to read, its too advance.
    Need to have a code with beginner to intermediate level.

    thanks,

    Mark


    M P Guest

  2. Similar Questions and Discussions

    1. What's the easiest way to..user define class...datagrid..paging..sorting..
      I have a large number of user define class objects and want display in a datagrid and able to perform paging and column sorting. It seems using...
    2. Easiest way to integrate flash a database
      Hi I'm looking for the easiest way to integrate Flash MX with either SQL Server or Microsoft Access. I've looked at many tutorials on the net...
    3. Database Paging
      Is this possible?
    4. Database Paging using CGI Perl
      Dear Friends, I am using Informix database. I want to implement database paging concept on Informix using CGI Perl. Please provide me any...
    5. Easiest way to compare schemas of two database. HOW???
      Hi, I need to compare schema (tables, fields, indexes, triggers) between two databases. Does IBM have any tool to do that? Best regards, K
  3. #2

    Default Re: Easiest Code for Database Paging

    Hi, I am passing for you a code in vbscript easy, so you can translate it to
    jscript, follows:
    ---------------------

    <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
    <%
    Option Explicit 'força declaração de variável, TEM QUE SER A 1ª DECLARAÇÃO
    APÓS A DIRETIVA @LANGUAGE.......
    Response.Expires = -1 'evita cache no servidor, mostra a versão mais atual
    da página.
    %>
    <html>
    <head>
    <title>Exemplo de P&aacute;gina&ccedil;&atilde;o</title>
    </head>
    <!-- #include file="adovbs.inc" -->
    <!-- #include file="conn_dbAT.asp" -->
    <body>
    <%
    'Variáveis de páginação
    Dim iPageSize 'Define quão grande será cada página
    Dim iPageCount 'O nº de páginas para se movimentar pelo recordset
    Dim iPageCurrent 'A página corrente(atual)
    Dim strSQL 'String SQL a ser executada
    Dim Rs 'Objeto de recordset
    Dim iRecordsShown 'Controlador de loop p/ mostrar exatamente os registros
    de cada tamanho de página(iPageSize)
    Dim I 'Usada no loop dos laços for
    Dim Mostrado 'Registro mostrado na tela

    '»»Parâmetros passados para paginação
    iPageSize = 10 'Aqui pode-se aumentar ou diminuir o nº de registros por
    página.

    'Recupera página p/ apresentar ou seta como default 1 a página atual
    If Request.QueryString("PaginaMostrada") = "" Then
    iPageCurrent = 1
    Else
    iPageCurrent = CInt(Request.QueryString("PaginaMostrada"))
    End If
    '»»Parâmetros passados para paginação

    'SE FOREM USADOS PARÂMETROS NA CONSULTA SQL, SERÁ PRECISO PASSÁ-LOS NA URL
    strSQL = "Select
    ATCod,AtDtAtend,AtHrAtend,AtContato,AtServico,AtSo lucionado,AtSolicitacao,At
    Descr,AtSolucao,AtAtendente from HT_DBAU001_DAtend WHERE AtCod = 5000 ORDER
    BY AtDtAtend"
    'Response.Write "<b>strSQL</b>:<br>" & strSQL & "<BR>"
    'Response.End()

    Set Rs = Server.CreateObject("adodb.recordset") '»»É preciso declarar o
    recordset dessa forma qdo. usa-se RS.Open
    Rs.CursorLocation = adUseClient
    Rs.CursorType = adOpenForwardOnly 'tipo do cursor
    Rs.LockType = adLockOptimistic 'tipo de bloqueio do cursor
    Rs.CacheSize = iPageSize
    Rs.PageSize = iPageSize
    Rs.Open strSQL,Conexao '»»Abre-se o recordset desta forma qdo. precisa de
    usar seus vários métodos e propridades

    'Contador de páginas
    iPageCount = Rs.PageCount

    'Se houver mais páginas a serem exibidas, a pág. corrente será = ao contador
    de pág.
    If iPageCurrent > iPageCount Then iPageCurrent = iPageCount
    'Se não houver mais páginas a serem exibidas, a página corrente será 1
    If iPageCurrent < 1 Then iPageCurrent = 1

    'Verifique a contagem da página para impedir bombardear quando os resultados
    zero são retornados!
    If iPageCount > 0 Then
    ' Move para página selecionada.
    Rs.AbsolutePage = iPageCurrent
    'Inicia saída com uma Página X de N linha
    %>
    <p>
    <font size="3">Página <strong><%= iPageCurrent %></strong>
    de <strong><%= iPageCount %></strong></font>
    </p>
    <%
    'Loop através dos registros e saída 1 linha por registro
    iRecordsShown = 0
    Do While iRecordsShown < iPageSize And Not Rs.EOF
    Mostrado = Rs("AtContato") & ""
    Mostrado = Replace(Mostrado,Chr(0),"")
    Response.Write "<b>Nome:</b>&nbsp;" & Mostrado & "<br>"
    ' Incrementa o nº de registros apresentados
    iRecordsShown = iRecordsShown + 1
    'Não esquecer de mover p/ próximo registro!
    Rs.MoveNext
    Loop
    End If
    Response.Write "<br><br>"

    '»»INÍCIO: Mostrar links anterior e próxima e nºs de página.
    If iPageCurrent > 1 Then '»»Mostra link p/ pág. anterior.
    %>
    <a href="exemp_paginacao.asp?PaginaMostrada=<%= iPageCurrent - 1
    %>">[&lt;&lt; Anterior]</a>
    <%
    End If

    '»»INÍCIO: Apresentar nº de páginas.
    For I = 1 To iPageCount
    'Só montará link c/ o Nº da pág. se não for a pág. corrente
    If I = iPageCurrent Then
    Response.Write "<strong>" & I & "</strong>"
    Else
    %>
    <a href="exemp_paginacao.asp?PaginaMostrada=<%=I%>">< %=I%></a>
    <%
    End If
    Next
    '»»FIM: Apresentar nº de páginas.

    If iPageCurrent < iPageCount Then '»»Mostra link p/ pág. posterior.
    %>
    <a href="exemp_paginacao.asp?PaginaMostrada=<%=iPageC urrent + 1%>">[Próxima
    &gt;&gt;]</a>
    <%
    End If
    '»»FIM: Mostrar links anterior e próxima e nºs de página.
    %>
    </body>
    </html>

    --

    Bye,

    ««««««««»»»»»»»»»»»»»»
    Vlmar Brazão de Oliveira
    Desenvolvimento Web
    HI-TEC


    "M P" <mark@textguru.ph> escreveu na mensagem
    news:OfnYHdLAEHA.1548@TK2MSFTNGP12.phx.gbl...
    > Can anyone help me find a code for Database Paging?
    >
    > I have seen some of it but its very hard for me to read, its too advance.
    > Need to have a code with beginner to intermediate level.
    >
    > thanks,
    >
    > Mark
    >
    >

    Vilmar Brazão de Oliveira Guest

  4. #3

    Default Re: Easiest Code for Database Paging

    On Wed, 3 Mar 2004 08:35:41 +0800, "M P" <mark@textguru.ph> wrote:
    >Can anyone help me find a code for Database Paging?
    >
    >I have seen some of it but its very hard for me to read, its too advance.
    >Need to have a code with beginner to intermediate level.
    It's quite possible that's because there is no "beginner" code for
    database paging. :)

    One good example is:

    [url]http://www.asp101.com/samples/db_paging.asp[/url]

    You may wish to do this client side, thusly:

    [url]http://www.4guysfromrolla.com/webtech/050901-1.shtml[/url]

    Otherwise, aspfaq.com, aspin.com and a Google for "ASP Database
    Paging" will turn you on to many options.

    Jeff
    Jeff Cochran Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139