Ir para conteúdo
Fórum Script Brasil
  • 0

Ajuda com Paginação em ASP/ACCESS


Eduardo Gonçalves

Pergunta

Salve camaradas... preciso paginar uns resultados em asp e estou encontrando problemas... estou tentando implementar um script sugerido aqui no fórum mas não estou conseguindo... Gostaria de saber se poderia contar com a ajuda de vocês...

Seguem os códigos...

Trecho da conexão com o banco e definição de páginas

<%
    Set bd = Server.CreateObject("ADODB.Connection")
    Set tb = Server.CreateObject("ADODB.Recordset")
    tb.CursorType = 1
    tb.CursorLocation = 3
    tb.LockType = 2  
    bd.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\bdadmin.mdb;Persist Security Info=False;"

    tb.PageSize = 10
    
    Set idlinha = Request.QueryString("idlinha")
    Set idsublinha = Request.QueryString("idsublinha")
    Set t = Request.QueryString("t")
    Set idr = Request.QueryString("id")
    
    if(isEmpty(idsublinha) or idsublinha="") then
        idsublinha = 0
            sql = "SELECT * FROM tbprodutos WHERE idlinha = " & idlinha & ""
    else
            sql = "SELECT * FROM tbprodutos WHERE idlinha = " & idlinha & "AND idsublinha = " & idsublinha & ""
    end if
    
    tb.Open sql, bd    
    
    'Criamos as Validações
    if Request.QueryString("pagina")="" then 
      intpagina = 1
    else
      if cint(Request.QueryString("pagina"))<1 then
        intpagina = 1
      else
        if cint(Request.QueryString("pagina"))>tb.PageCount then  
            intpagina = tb.PageCount
         else
            intpagina = Request.QueryString("pagina")
        end if
      end if    
    end if 
%>
Trecho que cria os links
<%
    if intpagina>1 then 
        Response.Write("<a href='produtos2.asp?pagina=" & intpagina-1 & "&idlinha=" & idlinha & "&idsublinha=" & idsublinha & "'>Anterior</a>&nbsp;&nbsp;") 
    end if
    if StrComp(intpagina,tb.PageCount)<>0 then   
           Response.Write("<a href='produtos2.asp?pagina=" & intpagina + 1 & "&idlinha=" & idlinha & "&idsublinha=" & idsublinha & "'>Próximo</a>")
    end if    
%>
E por fim, o trecho que pega os resultados da consulta
<%
    if tb.RecordCount>0 then
        Dim i, k
        Dim id(9)
        Dim thumb(9)
        Dim titulo(9)
        i = 0 
        tb.AbsolutePage = intpagina 
        intrec = 0
        While intrec<tb.PageSize and not tb.eof  
            id(i) = tb.Fields("id")
            thumb(i) = tb.Fields("thumb")
            titulo(i) = tb.Fields("titulo")            
            i = i+1
             tb.MoveNext
            intrec = intrec + 1
        Wend 
    end if    
%>
O que ocorre é que ao clicar no link 'Próximo', dá erro de tipo incompatível quando eu faço isto:
<% Response.Write("<a href='produtos_exibe.asp?id=" & id(0) & "' target='_blank'><img src='sendBinary.asp?path=c:\images\produtos\" & thumb(0) & "&width=89' border='0' /></a><br />" & titulo(0) & "") %>

Grato desde já pela ajuda de vocês...

Editado por Eduardo Gonçalves
Link para o comentário
Compartilhar em outros sites

9 respostass a esta questão

Posts Recomendados

  • 0
<img src='sendBinary.asp?path=c:\images\produtos\" & thumb(0) & "&width=89' border='0' />
Cara você deixou tudo junto...
"&width=89'
, deixe assim, separado
width='89'
Rode e poste o resultado !!!!
Ok mas o
"&width=89'
é para concatenar query strings... para ficar mais ou menos assim:
'sendBinary.asp?path=c:\images\produtos\foto1.jpg&width=89'

E tem outra coisa.... se o problema fosse aí... a primeira página não exibiria, certo??? Mas exibe... completa... só quando eu vou para a próxima que dá erro...

Editado por Eduardo Gonçalves
Link para o comentário
Compartilhar em outros sites

  • 0
<img src='sendBinary.asp?path=c:\images\produtos\" & thumb(0) & "&width=89' border='0' />
Cara você deixou tudo junto...
"&width=89'
, deixe assim, separado
width='89'
Rode e poste o resultado !!!!
Ok mas o
"&width=89'
é para concatenar query strings... para ficar mais ou menos assim:
'sendBinary.asp?path=c:\images\produtos\foto1.jpg&width=89'

E tem outra coisa.... se o problema fosse aí... a primeira página não exibiria, certo??? Mas exibe... completa... só quando eu vou para a próxima que dá erro...

Qual erro exatamente é imprimido na tela ????

Link para o comentário
Compartilhar em outros sites

  • 0

Erro de tempo de execução do Microsoft VBScript erro '800a000d'

Tipos incompatíveis

/produtos2.asp, line 248

E a linha 248 é exatamente a que mencionei antes:

<% Response.Write("<a href='produtos_exibe.asp?id=" & id(0) & "' target='_blank'><img src='sendBinary.asp?path=c:\images\produtos\" & thumb(0) & "&width=89' border='0' /></a><br />" & titulo(0) & "") %>

Att...

Link para o comentário
Compartilhar em outros sites

  • 0
Erro de tempo de execução do Microsoft VBScript erro '800a000d'

Tipos incompatíveis

/produtos2.asp, line 248

E a linha 248 é exatamente a que mencionei antes:

<% Response.Write("<a href='produtos_exibe.asp?id=" & id(0) & "' target='_blank'><img src='sendBinary.asp?path=c:\images\produtos\" & thumb(0) & "&width=89' border='0' /></a><br />" & titulo(0) & "") %>

Att...

Uma coisa, essa parte esta dentro do While ???? Vamos testando em partes, faz assim tire essa <img src='sendBinary.asp?path=c:\images\produtos\" & thumb(0) & "&width=89' border='0' /> e digite um texto, assim veremos se o erro é essa img...

Link para o comentário
Compartilhar em outros sites

  • 0

Ok... está melhorando... tirei a parte solicitada e a página 2 com os resultados apareceram... Mas quando fui para a página 3, nada... o erro persistiu e na mesma linha...

Eu tenho quase certeza que o erro está nos arrays thumb(), titulo() e id()... pois se tirar todas estas referências e apenas mandar por Response.Write um texto qualquer, ele imprime o texto... Acredito que ao passar para a próxima página, a consulta não esteja sendo refeita... Também não sei como funciona o ASP nesta maneira pos é minha primeira aventura com a linguagem....

Editado por Eduardo Gonçalves
Link para o comentário
Compartilhar em outros sites

  • 0

Ok...

<%@ codepage="1252" language="VBScript" %>
<% response.Charset="ISO-8859-1" %>
<%
    Set bd = Server.CreateObject("ADODB.Connection")
    Set tb = Server.CreateObject("ADODB.Recordset")
    tb.CursorType = 1
    tb.CursorLocation = 3
    tb.LockType = 2  
    bd.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\bdadmin.mdb;Persist Security Info=False;"

    tb.PageSize = 10
    
    Set idlinha = Request.QueryString("idlinha")
    Set idsublinha = Request.QueryString("idsublinha")
    Set t = Request.QueryString("t")
    Set idr = Request.QueryString("id")
    
    if(isEmpty(idsublinha) or idsublinha="") then
        idsublinha = 0
            sql = "SELECT * FROM tbprodutos WHERE idlinha = " & idlinha & ""
    else
            sql = "SELECT * FROM tbprodutos WHERE idlinha = " & idlinha & "AND idsublinha = " & idsublinha & ""
    end if
    
    tb.Open sql, bd    
    
    'Criamos as Validações
    if Request.QueryString("pagina")="" then 
      intpagina = 1
    else
      if cint(Request.QueryString("pagina"))<1 then
        intpagina = 1
      else
        if cint(Request.QueryString("pagina"))>tb.PageCount then  
            intpagina = tb.PageCount
         else
            intpagina = Request.QueryString("pagina")
        end if
      end if    
    end if 
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<style type="text/css">
body { font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px;
scrollbar-base-color: #c5e2cf;
//
scrollbar-track-color: #c5e2cf;
//
scrollbar-face-color: #c5e2cf;
//
scrollbar-highlight-color: #FFFFFF;
//
scrollbar-3d-light-color: #ffffff;
//
scrollbar-darkshadow-color: #65b384;
//
scrollbar-shadow-color: #65b384;
//
scrollbar-arrow-color: #000000;
};
.tahoma1 {
    font-family: Tahoma;
    font-size: 11px;
}
</style>
<style type="text/css">
<!--
.tahoma1J {
    font-family: Tahoma;
    font-size: 12px;
    text-align: justify;
    line-height: 18px;
    letter-spacing: normal;
}
a:link {
    font-family: Tahoma;
    font-size: 11px;
    text-decoration: none;
    color: #000000;
}
a:visited {
    font-family: Tahoma;
    font-size: 11px;
    text-decoration: none;
    color: #000000;
}
a:hover {
    font-family: Tahoma;
    font-size: 11px;
    text-decoration: underline;
    color: #000000;
}
a:active {
    font-family: Tahoma;
    font-size: 11px;
    color: #000000;
}
-->
</style>
<title>Vantagens</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->
</script>

<script language="JavaScript1.2" src="../menu_pulldown/mm_menu.js"></script>
<script LANGUAGE="JavaScript"> var javascript_version = 1.0; </SCRIPT>
<script LANGUAGE="JavaScript1.1">  javascript_version = 1.1; </SCRIPT>
<script LANGUAGE=JavaScript>

//****************************************
//* Abre nova janela centralizada na tela
//* Sintaxe: URL, Lagura, Altura, Scroll
//****************************************
function janela(URL,width,height,scroll)
   {
    xmax=screen.width;
    ymax=screen.height-28; 
    x=(xmax-(width+12))/2;
    y=(ymax-(height+29))/2;
    if (scroll) 
       scr_stat=" scrollbars=yes ";
    else 
       scr_stat=" scrollbars=no ";
    features="resizable=no height="+height+" width="+width+" left="+x+" top="+y+scr_stat;
    features=features+"toolbar=no location=no directories=no status=no menubar=no";
    newwin=window.open(URL,null,features);
    if(javascript_version > 1.0)
      setTimeout('newwin.focus();',250);
   }
</script>

<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
</head>

<body background="fundo_conteudos.gif" leftmargin="25" topmargin="20" marginwidth="00" marginheight="00">
<div id="Layer3" style="position:absolute; left:2px; top:457px; width:648px; height:19px; z-index:11"> 
  <p align="center" style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:9px;"><b>Mostrando 10 produtos.</b><br>
<%
    if intpagina>1 then 
        Response.Write("<a href='produtos2.asp?pagina=" & intpagina-1 & "&idlinha=" & idlinha & "&idsublinha=" & idsublinha & "'>Anterior</a>&nbsp;&nbsp;") 
    end if
    if StrComp(intpagina,tb.PageCount)<>0 then   
           Response.Write("<a href='produtos2.asp?pagina=" & intpagina + 1 & "&idlinha=" & idlinha & "&idsublinha=" & idsublinha & "'>Próximo</a>")
    end if    
%>


  </p> 
</div>
<div id="produtos" style="position:absolute; left:0; top:0; width:616px; height:274px; z-index:12">
<%
    if tb.RecordCount>0 then
        Dim i, k
        Dim id(9)
        Dim thumb(9)
        Dim titulo(9)
        i = 0 
        tb.AbsolutePage = intpagina 
        intrec = 0
        While intrec<tb.PageSize and not tb.eof  
            id(i) = tb.Fields("id")
            thumb(i) = tb.Fields("thumb")
            titulo(i) = tb.Fields("titulo")            
            i = i+1
             tb.MoveNext
            intrec = intrec + 1
        Wend 
    end if    
%>
  <table border="0" cellpadding="0" cellspacing="0" width="650">
    <!-- fwtable fwsrc="layout_catalogo.png" fwbase="layout_catalogo.gif" fwstyle="Dreamweaver" fwdocid = "742308039" fwnested="1" -->
    <tr> 
      <td><table border="0" cellpadding="0" cellspacing="0" width="650">
          <tr> 
            <td width="471" height="71" valign="middle" align="center"><%
                    Dim linha
                    Dim sublinha
                    select case(idlinha)
                        case 1:
                            linha = "Manipulados"
                        case 2:
                            linha = "Florais"
                        case 3:
                            linha = "Cosméticos"
                        case 4:
                            linha = "Produtos de revenda"
                        case 5:
                            linha = "Maquiagem Antialérgica"
                        case 6:
                            linha = "Linha de Banho"
                        case 7:
                            linha = "Acessórios"
                    end select
                    
                    select case(idsublinha)
                        case 1:
                            sublinha = " - Corpo"
                        case 2:
                            sublinha = " - Rosto"
                        case 3:
                            sublinha = " - Cabelo"
                        case 4:
                            sublinha = " - Mãos e Pés"
                        case 5:
                            sublinha = " - Proteção Solar"
                        case 6:
                            sublinha = " - Linha masculina"
                        case 7:
                            sublinha = " - Baton"
                        case 8:
                            sublinha = " - Lápis"
                        case 9:
                            sublinha = " - Rimel"
                        case 10:
                            sublinha = " - Sabonete"
                        case 11:
                            sublinha = " - Sais de banho"
                        case else
                            sublinha = ""
                    end select
                    
                    Response.Write("<h1>" & linha & "" & sublinha & "</h1>")
                %></td>
            <td><img name="layout_catalogo_r1_c10" src="images/layout_catalogo_r1_c10.gif" width="179" height="71" border="0" alt=""></td>
          </tr>
        </table></td>
    </tr>
    <tr> 
      <td><img name="layout_catalogo_r2_c1" src="images/layout_catalogo_r2_c1.gif" width="650" height="14" border="0" alt=""></td>
    </tr>
    <tr> 
      <td><table border="0" cellpadding="0" cellspacing="0" width="650">
          <tr> 
            <td width="17" height="198" background="images/layout_catalogo_r4_c13.gif">&nbsp;</td>
            <td><img name="layout_catalogo_r3_c2" src="images/layout_catalogo_r3_c2.gif" width="24" height="198" border="0" alt=""></td>
            <td><table border="0" cellpadding="0" cellspacing="0" width="92">
                <tr> 
                  <td width="92" height="92" valign="top"><div align="center" style="font-size:9px;"><% Response.Write("<a href='produtos_exibe.asp?id=" & id(0) & "' target='_blank'><img src='sendBinary.asp?path=c:\images\produtos\" & thumb(0) & "&width=89' border='0' /></a><br />" & titulo(0) & "") %></div></td>
                </tr>
                <tr> 
                  <td><img name="layout_catalogo_r5_c3" src="images/layout_catalogo_r5_c3.gif" width="92" height="12" border="0" alt=""></td>
                </tr>
                <tr> 
                  <td height="92" valign="top"><div align="center" style="font-size:9px;"><% Response.Write("<a href='produtos_exibe.asp?id=" & id(1) & "' target='_blank'><img src='sendBinary.asp?path=c:\images\produtos\" & thumb(1) & "&width=89' border='0' /></a><br />" & titulo(1) & "") %></div></td>
                </tr>
                <tr> 
                  <td><img name="layout_catalogo_r5_c3" src="images/layout_catalogo_r5_c3.gif" width="92" height="22" border="0" alt=""></td>
                </tr>
                <tr> 
                  <td height="92" valign="top"><div align="center" style="font-size:9px;"><% Response.Write("<a href='produtos_exibe.asp?id=" & id(2) & "' target='_blank'><img src='sendBinary.asp?path=c:\images\produtos\" & thumb(2) & "&width=89' border='0' /></a><br />" & titulo(2) & "") %></div></td>
                </tr>
              </table></td>
            <td><img name="layout_catalogo_r3_c4" src="images/layout_catalogo_r3_c4.gif" width="20" height="198" border="0" alt=""></td>
            <td><table border="0" cellpadding="0" cellspacing="0" width="92">
                <tr> 
                  <td width="92" height="92" valign="top"><div align="center" style="font-size:9px;"><% Response.Write("<a href='produtos_exibe.asp?id=" & id(3) & "' target='_blank'><img src='sendBinary.asp?path=c:\images\produtos\" & thumb(3) & "&width=89' border='0' /></a><br />" & titulo(3) & "") %></div></td>
                </tr>
                <tr> 
                  <td><img name="layout_catalogo_r5_c5" src="images/layout_catalogo_r5_c5.gif" width="92" height="12" border="0" alt=""></td>
                </tr>
                <tr> 
                  <td width="92" height="92" valign="top"><div align="center" style="font-size:9px;"><% Response.Write("<a href='produtos_exibe.asp?id=" & id(4) & "' target='_blank'><img src='sendBinary.asp?path=c:\images\produtos\" & thumb(4) & "&width=89' border='0' /></a><br />" & titulo(4) & "") %>
                      <table border="0" cellpadding="0" cellspacing="0" width="92">
                        <tr> 
                          <td><img name="layout_catalogo_r5_c5" src="images/layout_catalogo_r5_c5.gif" width="92" height="22" border="0" alt=""></td>
                        </tr>
                        <tr> 
                          <td width="92" height="92" valign="top"><div align="center"></div></td>
                        </tr>
                      </table>
                    </div></td>
                </tr>
              </table></td>
            <td><img name="layout_catalogo_r3_c6" src="images/layout_catalogo_r3_c6.gif" width="21" height="198" border="0" alt=""></td>
            <td><table border="0" cellpadding="0" cellspacing="0" width="92">
                <tr> 
                  <td width="92" height="92" valign="top"><div align="center" style="font-size:9px;"><% Response.Write("<a href='produtos_exibe.asp?id=" & id(5) & "' target='_blank'><img src='sendBinary.asp?path=c:\images\produtos\" & thumb(5) & "&width=89' border='0' /></a><br />" & titulo(5) & "") %></div></td>
                </tr>
                <tr> 
                  <td><img name="layout_catalogo_r5_c7" src="images/layout_catalogo_r5_c7.gif" width="92" height="12" border="0" alt=""></td>
                </tr>
                <tr> 
                  <td height="92" valign="top"><div align="center" style="font-size:9px;"><% Response.Write("<a href='produtos_exibe.asp?id=" & id(6) & "' target='_blank'><img src='sendBinary.asp?path=c:\images\produtos\" & thumb(6) & "&width=89' border='0' /></a><br />" & titulo(6) & "") %></div></td>
                </tr>
                <tr> 
                  <td><img name="layout_catalogo_r5_c7" src="images/layout_catalogo_r5_c7.gif" width="92" height="22" border="0" alt=""></td>
                </tr>
                <tr> 
                  <td width="92" height="92" valign="top"><div align="center"></div></td>
                </tr>
              </table></td>
            <td><img name="layout_catalogo_r3_c8" src="images/layout_catalogo_r3_c8.gif" width="22" height="198" border="0" alt=""></td>
            <td><table border="0" cellpadding="0" cellspacing="0" width="91">
                <tr> 
                  <td width="91" height="92" valign="top"><div align="center" style="font-size:9px;"><% Response.Write("<a href='produtos_exibe.asp?id=" & id(7) & "' target='_blank'><img src='sendBinary.asp?path=c:\images\produtos\" & thumb(7) & "&width=89' border='0' /></a><br />" & titulo(7) & "") %></div></td>
                </tr>
                <tr> 
                  <td><img name="layout_catalogo_r5_c9" src="images/layout_catalogo_r5_c9.gif" width="91" height="12" border="0" alt=""></td>
                </tr>
                <tr> 
                  <td width="91" height="92" valign="top"><div align="center" style="font-size:9px;"><% Response.Write("<a href='produtos_exibe.asp?id=" & id(8) & "' target='_blank'><img src='sendBinary.asp?path=c:\images\produtos\" & thumb(8) & "&width=89' border='0' /></a><br />" & titulo(8) & "") %>
                      <table border="0" cellpadding="0" cellspacing="0" width="91">
                        <tr> 
                          <td><img name="layout_catalogo_r5_c9" src="images/layout_catalogo_r5_c9.gif" width="91" height="22" border="0" alt=""></td>
                        </tr>
                        <tr> 
                          <td width="91" height="92" valign="top"><div align="center"></div></td>
                        </tr>
                      </table>
                    </div></td>
                </tr>
              </table></td>
            <td><img name="layout_catalogo_r3_c10" src="images/layout_catalogo_r3_c10.gif" width="21" height="198" border="0" alt=""></td>
            <td><table border="0" cellpadding="0" cellspacing="0" width="91">
                <tr> 
                  <td width="91" height="92" valign="top"><div align="center" style="font-size:9px;"><% Response.Write("<a href='produtos_exibe.asp?id=" & id(9) & "' target='_blank'><img src='sendBinary.asp?path=c:\images\produtos\" & thumb(9) & "&width=89' border='0' /></a><br />" & titulo(9) & "") %></div></td>
                </tr>
                <tr> 
                  <td><img name="layout_catalogo_r5_c11" src="images/layout_catalogo_r5_c11.gif" width="91" height="12" border="0" alt=""></td>
                </tr>
                <tr> 
                  <td height="92" valign="top"><div align="center"></div></td>
                </tr>
                <tr> 
                  <td><img name="layout_catalogo_r5_c11" src="images/layout_catalogo_r5_c11.gif" width="91" height="22" border="0" alt=""></td>
                </tr>
                <tr> 
                  <td width="91" height="91" valign="top">&nbsp;</td>
                </tr>
              </table></td>
            <td valign="top"><img name="layout_catalogo_r3_c12" src="images/layout_catalogo_r3_c12.gif" width="37" height="198" border="0" alt=""></td>
            <td valign="top" background="images/layout_catalogo_r4_c13.gif"> 
              <table width="30" height="100%" border="0" cellpadding="0" cellspacing="0">
                <tr> 
                  <td valign="top"><img src="images/layout_catalogo_r3_c13.gif" alt="" name="layout_catalogo_r3_c13" width="30" height="21" border="0" align="top"></td>
                </tr>
                <tr> 
                  <td width="30" height="178" background="images/layout_catalogo_r4_c13.gif">&nbsp;</td>
                </tr>
              </table>
            </td>
          </tr>
        </table></td>
    </tr>
    <tr> 
      <td><img name="layout_catalogo_r7_c1" src="images/layout_catalogo_r7_c1.gif" width="650" height="24" border="0" alt=""></td>
    </tr>
  </table>
</div>
</body>
</html>

Link para o comentário
Compartilhar em outros sites

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,1k
    • Posts
      651,8k
×
×
  • Criar Novo...