Ask a Question related to ASP Database, Design and Development.
-
M P #1
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
-
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... -
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... -
Database Paging
Is this possible? -
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... -
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 -
Vilmar Brazão de Oliveira #2
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áginaçã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> " & 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
%>">[<< 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
>>]</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
-
Jeff Cochran #3
Re: Easiest Code for Database Paging
On Wed, 3 Mar 2004 08:35:41 +0800, "M P" <mark@textguru.ph> wrote:
It's quite possible that's because there is no "beginner" code for>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.
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



Reply With Quote

