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

Exibindo Lista de Clientes


Paulo Faustini Jr

Pergunta

Estou querendo exibir uma lista de clientes da empresa, onde esta lista está armazenada em MDB, consegui fazer a conexão com o BD, mas na hora de exibir a listagem, me é exibido apenas os 10 primeiros, os outros (que estariam nas próximas páginas), não são exibidos. Meu código está ficando assim:

<% @ LANGUAGE="VBSCRIPT" %>
<% Response.Expires = 0 %>
<%

Response.Expires = 0

'******* Conecta � Base de Dados
set conn = createobject("adodb.connection")
conn.open "provider=microsoft.jet.oledb.4.0; data source=" & server.mappath("/pages/bd.mdb")
set rs = createobject("adodb.recordset")
set rs.activeconnection = conn

'******* Carrega Parametro do Formul�rio
ini = Request.Querystring("ini")
rad = Request.Form("radio")
cid = Request.Form("cidade")
est = Request.Form("estado")
pai = Request.Form("pais")
img = Request.Form("logo")
web = Request.Form("site")


rad = replace(server.HTMLEncode(rad),"'","`")
cid = replace(server.HTMLEncode(cid),"'","`")
est = replace(server.HTMLEncode(est),"'","`")
pai = replace(server.HTMLEncode(pai),"'","`")
img = replace(server.HTMLEncode(img),"'","`")
web = replace(server.HTMLEncode(web),"'","`")

'******* Verifica e Inclui Novo Registo (inativo)
if (rad <> "" AND cid <> "" AND est <> "" AND pai <> "" AND img <> "" AND web <> "") then
sqli = "INSERT INTO clientes (radio,cidade,estado,pais,logo,site) VALUES ('" & rad & "','" & cid & "','" & est & "','" & pai & "','" & img & "','" & web & "')"
rs.open sqli
ini = 1
end if

'******* Inicializa Variaveis
ini = int(ini)
if ini <= 0 then ini = 1 end if
reg = 0
npg = 10
pgt = ini - 1
voltar = "Voltar"


'******* Consulta BD e lista Clientes
sql = "SELECT * FROM clientes WHERE estado='" & Request("estados") & "' "
rs.open sql

do while not rs.eof
reg = reg + 1
if rs("site") <> "" then
   site = " - <a href='http://" & rs("site") & "'>[Site]</a>"
   else
   site = " - [Site]"
end if
if rs("logo") <> "" then
    logo = "<img src=" &rs("logo") & " width='"40"' height='"40"'>"
end if
if reg >= ini AND reg <= ini+npg-1 then
pgt = pgt + 1
clientes = clientes & "<table width="200" border="0">  <tr>    <th rowspan="2" scope="col">logo</th>    <th scope="col">" & rs("radio") & "</th>
<th scope="col">" & site & "</th>   </tr>  <tr>    <th colspan="2" scope="row">" & rs("cidade") & "," & rs("estado") & "-" & rs("pais") & "</th>
</tr></table>"
end if

 rs.movenext
 loop
 if reg > ini+npg-1 then
   proximo = " <a href='default.asp?ini=" & ini + npg & "'> [ Pr�ximos ]</a>"
   else
   proximo = " [ Pr�ximos ]"
 end if
 if ini-npg > 0 then
   voltar = " <a href='default.asp?ini=" & ini - npg & "'> [ Anteriores ]</a>"
   else
   voltar = " [ Anteriores ]"
 end if

%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Nossos Clientes</title>
</head>

<body>
<tr>
<td align="middle" bgColor="#004184" colSpan="2" width="436">
      <font face="Tahoma" style="font-size: 9pt">
            <span style="COLOR: #CEE4F5"><b>Clientes - <% Response.Write est %></b>
            </span>
      </font>
</td>
</tr>
<% Response.Write clientes %>
<font face="Tahoma" style="font-size: 9pt" color="#004184"></font>
<tr bgColor="#ffffff">
    <td width="150">
        <font face="Tahoma" style="font-size: 9pt">
              <span style="COLOR: #004184">
                    <b>&nbsp;Total: <% Response.Write reg %>
                    </b>
              </span>
        </font>
    </td>
    <td align="right" width="280">
        <span style="FONT-SIZE: 13px; COLOR: black">
              <% Response.Write ini & " a " & pgt & " - " & voltar & proximo %>
        </span>
        <span style="FONT-SIZE: 9pt; ">
              <font color="#004184" face="Tahoma"><br>
              </font>
        </span>
    </td>
</tr>
</body>
</html>

abs

Link para o comentário
Compartilhar em outros sites

3 respostass a esta questão

Posts Recomendados

  • 0

Sua SQL está assim:

sql = "SELECT * FROM clientes WHERE estado='" & Request("estados") & "' "
Porém no link da paginação, você faz isso:
proximo = " <a href='default.asp?ini=" & ini + npg & "'> [ Próximos ]</a>"
Na primeira página, possivelmente vem através do formulário o estado. Na segunda página, não vai de lugar algum, portanto a SQL fica assim:
sql = "SELECT * FROM clientes WHERE estado=''"
Nesse caso, possivelmente nãoe existe nenhum campo que o estado está em branco, por isso não retorna nada. Arruma os links da paginação para passar também a variável estados. Algo como:
proximo = " <a href='default.asp?ini=" & ini + npg & "&estados="& Request("estados") &"'> [ Próximos ]</a>"

Abraço!

Editado por Bicicleta
Link para o comentário
Compartilhar em outros sites

  • 0

caramba, mandei código errado... foi malz... e na verdade é conexao com SQL... o código é esse aqui:

<%@LANGUAGE="VBSCRIPT"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Clientes Playlist</title>

<!-- Função que consulta os estados no BD -->
<%
//DADOS BD
host    ="playlist.com.br"
usuario    ="enqueteplaylist"
senha    ="***"
banco    ="EnquetesSitePlaylist"

//CONEXÃO AO BD
set conexao =Server.CreateObject("Adodb.Connection")
conexao.ConnectionString ="ODBC;DSN=SQL;Driver=SQL Server;Server=playlist.com.br;uid=enqueteplaylist;pwd=***;database=EnquetesSitePlaylist"
conexao.Open

//CONSULTA AO BD
set rs =conexao.execute("SELECT * FROM clientes where estado='MG' ")

'******* Inicializa Variaveis
ini = int(ini)
if ini <= 0 then ini = 1 end if
reg = 0
npg = 6
pgt = ini - 1
voltar = "Voltar"

'******* Consulta e Exibe Resultados
do while not rs.eof
reg = reg + 1
if rs("site") <> "" then
   site = " - <a href='http://" & rs("site") & "'>[Site]</a>"
   else
   site = " - [Site]"
end if
if reg >= ini AND reg <= ini+npg-1 then
pgt = pgt + 1
radios = radios & "<p><font face='Tahoma' style='font-size: 9pt'>" & "<strong>" & rs("radio") & "</strong>" & site & "</p>" & "<p>" & rs("cidade") & ", " & rs("estado") & " - " & rs("pais") & "</font></p><br />"
end if

 rs.movenext
 loop
 if reg > ini+npg-1 then
   proximo = " <a href='teste.asp?ini=" & ini + npg & "'> [ Próximos ]</a>"
   else
   proximo = " [ Próximos ]"
 end if
 if ini-npg > 0 then
   voltar = " <a href='teste.asp?ini=" & ini - npg & "'> [ Anteriores ]</a>"
   else
   voltar = " [ Anteriores ]"
 end if

%>

</head>

<body>
<tr>
<td align="middle" bgColor="#004184" colSpan="2" width="436">
      <font face="Tahoma" style="font-size: 9pt">
            <span style="COLOR: #CEE4F5"><b>Clientes - MG</b>
            </span>
      </font>
</td>
</tr>
<% Response.Write radios %>
<font face="Tahoma" style="font-size: 9pt" color="#004184"></font>
<tr bgColor="#ffffff">
    <td width="150">
        <font face="Tahoma" style="font-size: 9pt">
              <span style="COLOR: #004184">
                    <b>&nbsp;Total: <% Response.Write reg %>
                    </b>
              </span>
        </font>
    </td>
    <td align="right" width="280">
        <span style="FONT-SIZE: 13px; COLOR: black">
              <% Response.Write ini & " a " & pgt & " - " & voltar & proximo %>
        </span>
        <span style="FONT-SIZE: 9pt; ">
              <font color="#004184" face="Tahoma"><br>
              </font>
        </span>
    </td>
</tr>
</body>
</html>

eu não vou receber o estado de outro lugar, ele já será definido nesse código

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,2k
    • Posts
      651,9k
×
×
  • Criar Novo...