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

Paginação Da Erro !


Guest --Renato --

Pergunta

Guest --Renato --

Ola gente por gentileza me ajudem !! estou fazendo uma busca no banco de algumas informações e depois fazendo a paginação mais algo da errado e aparece o seguinte erro:

Tipo de erro:

ADODB.Recordset (0x800A0BB9)

Os argumentos são incorretos, estão fora do intervalo aceitável ou estão em conflito.

/SCC/teste.asp, line 38

Se alguém puder ajudar agradeço !!

<%

Response.CacheControl="no-cache"

Response.AddHeader "Pragma","no-cache"

Response.Expires = 0

Response.Buffer = True

<!-- #Include file="ADOVBS.INC" -->

%>

<%

Const IntPageSize = 10

Dim IntCurrentPage

Dim intTotalPages, intI

If Request.ServerVariables("CONTENT_LENGTH") = 0 THEN

IntCurrentPage= CInt(Request.Form("CurrentPage"))

Select Case Request.Form("Submit")

Case "Previous"

IntCurrentPage= intCurrentpage -1

Case "Next"

intCurrentPage=intCurrentPage +1

End Select

End If

Dim con

Dim rs

Dim strCon

Set con = Server.CreateObject("ADODB.Connection")

strCon ="Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=SCC; Pwd=beta; Data Source=BETA"

con.Open strCon

Set rs = Server.CreateObject("ADODB.Recordset")

rs.Cursorlocation = adUseClient

rs.CursorType = adOpenStatic

rs.CacheSize = IntPageSize

If selec_opc = "id_empresa" and IsNumeric(busca) then

'SQL= "Select * From SCC_EMPRESA Where ID_EMPRESA = '" & busca & "' Order by ID_EMPRESA"

'Else

SQL= "Select ID_EMPRESA, NOME_FANTASIA, CEP From SCC_EMPRESA Where NOME_FANTASIA LIKE '%a%' Order by Nome_Fantasia"

End IF

rs.Open SQL, Con, , , adCmdText

rs.PageSize = IntPageSize

If Not(rs.eof) then

rs.absolutePage = intCurrentPage

intTotalPages = rs.PageCount

%>

<%

For IntI = 1 To rs.PageSize

%>

<%=rs("id_empresa")%>

<%=rs("nome_fantasia")%>

<%=rs("cep")%>

<%

rs.moveNext

If rs.eof then exit for

Next

%>

<%

re.close

con.close

Set rs = Nothing

Set con=nothing

%>

<input type="hidden" name="submit" value="<%="intCurrentPage"%>">

<br />

Pagina <%=intCurrentpage%> de <%=intTotalpage%>

<% If intCurrentPage > 1 Then %>

<input type="Submit" name="submit" value="Previous">

<% End If

If intCurrentPage <> intTotalpage Then %>

<input type="Submit" name="submit" value="Next">

<%

End IF

End IF

%>

Link para o comentário
Compartilhar em outros sites

2 respostass a esta questão

Posts Recomendados

  • 0

If selec_opc = "id_empresa" and IsNumeric(busca) then

'SQL= "Select * From SCC_EMPRESA Where ID_EMPRESA = '" & busca & "' Order by ID_EMPRESA"

'Else

SQL= "Select ID_EMPRESA, NOME_FANTASIA, CEP From SCC_EMPRESA Where NOME_FANTASIA LIKE '%a%' Order by Nome_Fantasia"

End IF

nessa parte você testa se busca é um numero... e na string você coloca a variavel como texto.... é assim mesmo???

faz um teste assim...

If selec_opc = "id_empresa" and IsNumeric(busca) then

'SQL= "Select * From SCC_EMPRESA Where ID_EMPRESA = " & busca & " Order by ID_EMPRESA"

'Else

SQL= "Select ID_EMPRESA, NOME_FANTASIA, CEP From SCC_EMPRESA Where NOME_FANTASIA LIKE '%a%' Order by Nome_Fantasia"

End IF

Link para o comentário
Compartilhar em outros sites

  • 0
Guest --Renato --
If selec_opc = "id_empresa" and IsNumeric(busca) then

'SQL= "Select * From SCC_EMPRESA Where ID_EMPRESA = '" & busca & "' Order by ID_EMPRESA"

'Else

SQL= "Select ID_EMPRESA, NOME_FANTASIA, CEP From SCC_EMPRESA Where NOME_FANTASIA LIKE '%a%' Order by Nome_Fantasia"

End IF

nessa parte você testa se busca é um numero... e na string você coloca a variavel como texto.... é assim mesmo???

faz um teste assim...

If selec_opc = "id_empresa" and IsNumeric(busca) then

'SQL= "Select * From SCC_EMPRESA Where ID_EMPRESA = " & busca & " Order by ID_EMPRESA"

'Else

SQL= "Select ID_EMPRESA, NOME_FANTASIA, CEP From SCC_EMPRESA Where NOME_FANTASIA LIKE '%a%' Order by Nome_Fantasia"

End IF

Sim coloquei a para testar, por que assim, caso seja selecionado para pesquisar por id empresa ele verifica se pode ser convertido e faz o select agora se for selecionado nome_fantasia ele cai no outro select, esse primeiro select funciona numa boa o problema acho que esta na minha paginação.

tem uma outra forma que fiz que executa normal mais quando faz a busca no banco ele traz tudo do banco ou seja se o cara digita A ele traz tudo que tem a mais traz também o que não tem a, ou seja o banco inteiro veja o codigo :

<%

Response.CacheControl="no-cache"

Response.AddHeader "Pragma","no-cache"

Response.Expires = 0

Response.Buffer = True

selec_opc=Request.Form("selec_opc")

busca=Request.Form("busca")

'Response.Write busca

Const nTamanhoPagina = 1

Dim nPaginaAtual

Dim PaginaAtual

Dim nTotalPaginas

Dim SQL

Dim x

if Request.Querystring = "" then

nPaginaAtual = 1

else

nPaginaAtual = Cint(Request.Querystring("PaginaAtual"))

Select Case Request.Querystring("Submit")

Case "Anterior"

nPaginaAtual = nPaginaAtual - 1

Case "Proxima"

nPaginaAtual = nPaginaAtual + 1

End Select

end if

Dim con

Dim rs

Dim strCon

Set con = Server.CreateObject("ADODB.Connection")

Set rs = Server.CreateObject("ADODB.Recordset")

strCon ="Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=SCC; Pwd=beta; Data Source=BETA"

con.Open strCon

rs.Cursorlocation = adUseClient

rs.CursorType = adOpenStatic

rs.CacheSize = nTamanhoPagina

If selec_opc = "id_empresa" and IsNumeric(busca) then

SQL= "Select * From SCC_EMPRESA Where ID_EMPRESA = '" & busca & "' Order by ID_EMPRESA"

Else

SQL= "Select ID_EMPRESA, NOME_FANTASIA, CEP From SCC_EMPRESA Where NOME_FANTASIA LIKE '%" & busca & "%' Order by Nome_Fantasia"

End IF

rs.Open sql,Con

rs.PageSize = nTamanhoPagina

If rs.EOF Then

response.redirect("busca_empresa.asp?msg01= Empresa não encontrada !<br> <a href=cadastro_emp.asp> Clique aqui caso deseje cadastrar</a>")

Response.End()

Else

rs.absolutePage = nPaginaAtual

nTotalPaginas = rs.Pagecount

%>

<!-- #Include file="ADOvb script:return valida_emp()" >

&nbsp;

&nbsp;<table style="width: 582px; height: 51px ; left: 55px; position: absolute; top: 112px;" id="table" > <tr>

<td style="width: 318px" rowspan="12" >

<ul id="nav">

<li><a href="busca_empresa.asp"> Empresa</a> </li>

<li><a href="busca_distribuidor.asp">Distribuidores</a> </li>

<li><a href="funcionario.asp">Funcionário</a> </li>

<li><a href="#">Cliente</a> </li>

<li><a href="">Telefone Cliente</a> </li>

<li><a href="">Tipo Telefone</a> </li>

<li style="left: 0px; top: 0px"><a href="cargo.aspx">Cargo</a> </li>

</ul>

</td>

<td style="width: 327px; height: 15px">

<span >Id Empresa</span></td>

<td style="width: 325px; height: 15px">

<input name="id_empresa" value="<%=rs("id_empresa")%>" type="text" style="width: 40px" maxlength="8" readonly="true"/>

*</td>

</tr>

<tr>

<td style="width: 327px; height: 15px">

Nome Fantasia</td>

<td style="width: 325px; height: 15px">

<input name="nome_fantasia" style="width: 205px" maxlength="50" value = "<%=rs("nome_fantasia")%>" >

*</td>

</tr>

<tr>

<td style="width: 327px">

Cep</td>

<td style="width: 325px"><input name="cep" value="<%=rs("cep")%>" type="text" id="Text3" style="width: 70px" maxlength="8" />

*</td>

</tr>

<tr>

<td style="width: 327px; height: 15px">

</td>

<td style="width: 325px; height: 15px">

</td>

</tr>

<tr>

<td style="width: 327px">

</td>

<td style="width: 325px">

</td>

</tr>

<tr>

<td style="width: 327px">

</td>

<td style="width: 325px">

</td>

</tr>

<tr>

<td style="width: 327px">

</td>

<td style="width: 325px">&nbsp;

</td>

</tr>

<tr>

<td style="width: 327px">

</td>

<td style="width: 325px">

</td>

</tr>

<tr>

<td style="width: 327px">

</td>

<td style="width: 325px">

</td>

</tr>

<tr>

<td style="width: 327px">

</td>

<td style="width: 325px">

</td>

</tr>

<tr>

<td style="width: 327px">

</td>

<td style="width: 325px">

</td>

</tr>

<tr>

<td style="height: 22px; text-align: center;" colspan="2">

<% response.write request.querystring("msg02")%>

<%If nPaginaAtual > 1 then %>

<a href="<%=request.servervariables("SCRIPT_NAME")%>?PaginaAtual=<%=nPaginaAtual%>&Submit=Anterior">Anterior |</a>

<%end if%>

<%If nPaginaAtual <> nTotalPaginas then %>

<a href="<%=request.servervariables("SCRIPT_NAME")%>?PaginaAtual=<%=nPaginaAtual%>&Submit=Proxima">Proxima</a>

<%

End If

%>

</td>

</tr>

<tr>

<td rowspan="1" style="width: 318px">

</td>

<td style="height: 22px; text-align: center;" colspan="2">

<a href="java script:valida_emp();"></a>&nbsp;<a href="java script:valida_emp();"><img src="images/bt_atualizar.jpg" border="0" /></a>

<a class="link" href="exclui_empresa.asp" onClick="document.forms..submit();return false">

<img src="images/bt_excluir.jpg" border="0" /></a>

</tr>

</table>

</form>

</td>

<td style="width: 39px; padding-right: 0px; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px; border-top-style: none; border-right-style: none; border-left-style: none; border-bottom-style: none; height: 290px;">

<img src="images/lat_direita.jpg" name="IMG2" height="356" border="0" id="IMG2" /></td>

</tr>

<tr>

<td colspan="3" style="height: 76px; padding-right: 0px; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px;">

<img src="images/rodape.jpg" /></td>

</tr>

</table>

</td>

</tr>

<tr>

</tr>

<tr>

</tr>

<%

End If

%>

<%

' Fechamos o recordset e liberamos a memória usada

rs.close

set rs=nothing

con.close

set con=nothing

%>

</table>

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