Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Como faço para a busca me retornar somente o número de páginas correspondentes ao registro solicitado e que ainda assim, quando retornar o um número superior a 1 página, como fazer com que as demais armazenem o da variavel?
Ou seja, o mesmo realiza a busca mas retorna numero superior de páginas, além disso o conteúdo da variável só funciona na primeira página, nas demias não!
Notei que o retorno da consulta é este: busca.asp?busca=ci
Quando me dirijo para a página seguinte é este: busca.asp?page=2
E que para funcionar deveria ser assim: busca.asp?page=3&busca=ci Obs."&busca=ci" adicionei manualmente no navegador.
Será que alguem poderia me ajudar a interpretar o erro?
Grato a todos!
Código abaixo:
<%
'Option Explicit
Const adOpenStatic = 3
Const adLockReadOnly = 1
Const adCmdText = &H0001
Dim CONN_STRING
CONN_STRING = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("../dados/goldnews.mdb")
Dim iPageSize
Dim iPageCount
Dim iPageCurrent
Dim strOrderBy
Dim strSQL
Dim objPagingConn
Dim objPagingRS
Dim iRecordsShown
Dim iFieldCount
Dim iRecordCount
Dim LoopRecordCount
Dim pageNum
Dim counter
Dim markShowPage
Dim I, J
'busca
Dim strBusca
'fields declaradas
Dim componente
Dim descricao
Dim part_number
Dim enc
Dim marca
Dim dc
Dim qtde
Dim condicao
strBusca = Request.QueryString("busca")
iPageSize = 300
If Request.QueryString("page") = "" Then
iPageCurrent = 1
Else
iPageCurrent = CInt(Request.QueryString("page"))
End If
strSQL = "SELECT * from lista WHERE descricao + ' - ' + componente LIKE '%"& strBusca &"%'order by id asc;"
Set objPagingConn = Server.CreateObject("ADODB.Connection")
objPagingConn.Open CONN_STRING
Set objPagingRS = Server.CreateObject("ADODB.Recordset")
objPagingRS.PageSize = iPageSize
objPagingRS.CacheSize = iPageSize
objPagingRS.Open strSQL, objPagingConn, adOpenStatic, adLockReadOnly, adCmdText
iPageCount = objPagingRS.PageCount
iFieldCount = objPagingRS.Fields.Count
iRecordCount = objPagingRS.RecordCount
If iPageCurrent > iPageCount Then iPageCurrent = iPageCount
If iPageCurrent < 1 Then iPageCurrent = 1
If iPageCount = 0 Then
Response.Write "Registro nao encontrado!"
Else
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style>
body {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
}
td {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
}
listingLink {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
font-weight: bold;
color: blue;
text-decoration:none;
margin-left:0px;
margin-right:0px;
}
a.listingLink:hover {
color:#FF0000;
}
activepage {
color:#ffffee;
background-color: #000033;
font-weight: bold;
}
</style>
</head>
<body topmargin="0" leftmargin="5" rightmargin="0" bottommargin="0" marginwidth="0" marginheight="0">
<table border="1" bordercolor=#FFFFFF cellpadding="6" cellspacing="0">
<tr><td></td>
<td style=width:164px; bgcolor=#000000 align="left"><font color=#ffffff face=Arial size=1><b>
COMPONENTE</b></td></font>
<td style=width:140px; bgcolor=#000000 align="left"><font color=#ffffff face=Arial size=1><b>
DESCRIÇÃO</b></td>
<td style=width:152px; bgcolor=#000000 align="left"><font color=#ffffff face=Arial size=1><b>
PART NUMBER</b></td>
<td style=width:38px; bgcolor=#000000 align="left"><font color=#ffffff face=Arial size=1><b>
ENC</b></td>
<td style=width:65px; bgcolor=#000000 align="left"><font color=#ffffff face=Arial size=1><b>
MARCA</b></td>
<td style=width:28px; bgcolor=#000000 align="left"><font color=#ffffff face=Arial size=1><b>
D/C</b></td>
<td style=width:30px; bgcolor=#000000 align="left"><font color=#ffffff face=Arial size=1><b>
QTDE</b></td>
<td style=width:92px; bgcolor=#000000 align="left"><font color=#ffffff face=Arial size=1><b>
CONDIÇÃO</b></td>
</tr>
<%
objPagingRS.AbsolutePage = iPageCurrent
Do While LoopRecordCount < iPageSize And Not objPagingRS.EOF
componente = objPagingRS("componente")
descricao = objPagingRS("descricao")
part_number = objPagingRS("part_number")
enc = objPagingRS("enc")
marca = objPagingRS("marca")
dc = objPagingRS("dc")
qtde = objPagingRS("qtde")
condicao = objPagingRS("condicao")
response.write "<tr>"
response.write "<td style=width:164px; bgcolor=#267F00><font color=#ffffff face=Arial size=1>" & componente & "</td></font>"
response.write "<td style=width:140px; bgcolor=#267F00><font color=#ffffff face=Arial size=1>" & descricao & "</td></font>"
response.write "<td style=width:152px; bgcolor=#267F00><font color=#ffffff face=Arial size=1>" & part_number & "</td></font>"
response.write "<td style=width:38px; bgcolor=#267F00><font color=#ffffff face=Arial size=1>" & enc & "</td></font>"
response.write "<td style=width:65px; bgcolor=#267F00><font color=#ffffff face=Arial size=1>" & marca & "</td></font>"
response.write "<td style=width:28px; bgcolor=#267F00><font color=#ffffff face=Arial size=1>" & dc & "</td></font>"
response.write "<td style=width:30px; bgcolor=#267F00><font color=#ffffff face=Arial size=1>" & qtde & "</td></font>"
response.write "<td style=width:92px; bgcolor=#267F00><font color=#ffffff face=Arial size=1>" & condicao & "</td></font>"
response.write "</tr>"
LoopRecordCount = LoopRecordCount + 1
objPagingRS.MoveNext
Loop
objPagingRS.Close
Set objPagingRS = Nothing
objPagingConn.Close
Set objPagingConn = Nothing
End If
iRecordCount = iRecordCount - 1
iFieldCount = iFieldCount - 1
LoopRecordCount = LoopRecordCount - 1
pageNum = Round(iRecordCount/iPageSize)
If pageNum < (iRecordCount/iPageSize) Then pageNum = pageNum + 1
Response.Write " <b>"
For counter = 1 To pageNum
if counter=iPageCurrent then
Response.Write " <span class=activepage> "
Response.Write counter
Response.Write " </span>"
markShowPage=1
else
Response.Write " <a onclick=exitoff() href=busca.asp?page="
Response.Write counter
Response.Write " class=listingLink>"
Response.Write counter
Response.Write "</a>"
end ifResponse.Write " "
Response.Write "<b>"
Response.Write "<a href=busca.asp?page="
If iPageCurrent = 1 Then
Response.Write pageNum
else
Response.Write iPageCurrent-1
end if
Response.Write " class=listingLink>anterior</a> "
Response.Write "<a href=busca.asp?page="
If iPageCurrent = pageNum Then
Response.Write "1"
else
Response.Write iPageCurrent+1
end if
Response.Write " class=listingLink>proximo</a>"
Response.Write "</b>"
%>
</body>
</table>
</html>Carregando comentários...