Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Thiago Barraviera

ADODB.Field erro '800a0bcd'

Recommended Posts

Olá pessoal, estou quebrando a cabeça aqui com o tal do ASP.

 

Me código esta gerando o seguinte erro:

 

ADODB.Field erro '800a0bcd'

BOF ou EOF são verdadeiros, ou o registro atual foi excluído. A operação solicitada pelo aplicativo requer um registro atual.

/sessao.asp, line 373

 

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/dados.asp" -->
<%
Dim rimo__MMColParam2
rimo__MMColParam2 = "1"
If (Request.QueryString("valor") <> "") Then 
 rimo__MMColParam2 = Request.QueryString("valor")
End If
%>
<%
Dim rimo__MMColParam
rimo__MMColParam = "1"
If (Request.QueryString("Cod_tipo") <> "") Then 
 rimo__MMColParam = Request.QueryString("Cod_tipo")
End If
%>
<%
Dim rimo
Dim rimo_numRows

Set rimo = Server.CreateObject("ADODB.Recordset")
rimo.ActiveConnection = MM_dados_STRING
rimo.Source = "SELECT *  FROM Imoveis  WHERE Cod_tipo = " + Replace(rimo__MMColParam, "'", "''") + " AND valor <= " + Replace(rimo__MMColParam2, "'", "''") + " AND Ativo = 'Sim'  ORDER BY valor ASC"
rimo.CursorType = 0
rimo.CursorLocation = 2
rimo.LockType = 1
rimo.Open()

rimo_numRows = 0
%>
<%
Dim rdst
Dim rdst_cmd
Dim rdst_numRows

Set rdst_cmd = Server.CreateObject ("ADODB.Command")
rdst_cmd.ActiveConnection = MM_dados_STRING
rdst_cmd.CommandText = "SELECT * FROM Imoveis WHERE Destaque = 'Sim' ORDER BY valor ASC" 
rdst_cmd.Prepared = true

Set rdst = rdst_cmd.Execute
rdst_numRows = 0
%>
<%
Dim rimomostra
Dim rimomostra_numRows

Set rimomostra = Server.CreateObject("ADODB.Recordset")
rimomostra.ActiveConnection = MM_dados_STRING
rimomostra.Source = "SELECT * FROM Tipo ORDER BY Tipo ASC"
rimomostra.CursorType = 0
rimomostra.CursorLocation = 2
rimomostra.LockType = 1
rimomostra.Open()

rimomostra_numRows = 0
%>
<%
Dim rtipo__MMColParam
rtipo__MMColParam = "1"
If (Request.QueryString("Cod_tipo") <> "") Then 
 rtipo__MMColParam = Request.QueryString("Cod_tipo")
End If
%>
<%
Dim rtipo
Dim rtipo_numRows

Set rtipo = Server.CreateObject("ADODB.Recordset")
rtipo.ActiveConnection = MM_dados_STRING
rtipo.Source = "SELECT * FROM Tipo WHERE Cod_tipo = " + Replace(rtipo__MMColParam, "'", "''") + ""
rtipo.CursorType = 0
rtipo.CursorLocation = 2
rtipo.LockType = 1
rtipo.Open()

rtipo_numRows = 0
%>
<%
Dim HLooper1__numRows
HLooper1__numRows = 6
Dim HLooper1__index
HLooper1__index = 0
rdst_numRows = rdst_numRows + HLooper1__numRows
%>
<%
Dim HLooper2__numRows
HLooper2__numRows = 12
Dim HLooper2__index
HLooper2__index = 0
rimo_numRows = rimo_numRows + HLooper2__numRows
%>

<%
'  *** Recordset Stats, Move To Record, and Go To Record: declare stats variables

' set the record count
rimo_total = rimo.RecordCount

' set the number of rows displayed on this page
If (rimo_numRows < 0) Then
 rimo_numRows = rimo_total
Elseif (rimo_numRows = 0) Then
 rimo_numRows = 1
End If

' set the first and last displayed record
rimo_first = 1
rimo_last  = rimo_first + rimo_numRows - 1

' if we have the correct record count, check the other stats
If (rimo_total <> -1) Then
 If (rimo_first > rimo_total) Then rimo_first = rimo_total
 If (rimo_last > rimo_total) Then rimo_last = rimo_total
 If (rimo_numRows > rimo_total) Then rimo_numRows = rimo_total
End If
%>
<%
' *** Recordset Stats: if we don't know the record count, manually count them

If (rimo_total = -1) Then

 ' count the total records by iterating through the recordset
 rimo_total=0
 While (Not rimo.EOF)
   rimo_total = rimo_total + 1
   rimo.MoveNext
 Wend

 ' reset the cursor to the beginning
 If (rimo.CursorType > 0) Then
   rimo.MoveFirst
 Else
   rimo.Requery
 End If

 ' set the number of rows displayed on this page
 If (rimo_numRows < 0 Or rimo_numRows > rimo_total) Then
   rimo_numRows = rimo_total
 End If

 ' set the first and last displayed record
 rimo_first = 1
 rimo_last = rimo_first + rimo_numRows - 1
 If (rimo_first > rimo_total) Then rimo_first = rimo_total
 If (rimo_last > rimo_total) Then rimo_last = rimo_total

End If
%>
<%
' *** Move To Record and Go To Record: declare variables

Set MM_rs    = rimo
MM_rsCount   = rimo_total
MM_size      = rimo_numRows
MM_uniqueCol = ""
MM_paramName = ""
MM_offset = 0
MM_atTotal = false
MM_paramIsDefined = false
If (MM_paramName <> "") Then
 MM_paramIsDefined = (Request.QueryString(MM_paramName) <> "")
End If
%>
<%
' *** Move To Record: handle 'index' or 'offset' parameter

if (Not MM_paramIsDefined And MM_rsCount <> 0) then

 ' use index parameter if defined, otherwise use offset parameter
 r = Request.QueryString("index")
 If r = "" Then r = Request.QueryString("offset")
 If r <> "" Then MM_offset = Int(r)

 ' if we have a record count, check if we are past the end of the recordset
 If (MM_rsCount <> -1) Then
   If (MM_offset >= MM_rsCount Or MM_offset = -1) Then  ' past end or move last
     If ((MM_rsCount Mod MM_size) > 0) Then         ' last page not a full repeat region
       MM_offset = MM_rsCount - (MM_rsCount Mod MM_size)
     Else
       MM_offset = MM_rsCount - MM_size
     End If
   End If
 End If

 ' move the cursor to the selected record
 i = 0
 While ((Not MM_rs.EOF) And (i < MM_offset Or MM_offset = -1))
   MM_rs.MoveNext
   i = i + 1
 Wend
 If (MM_rs.EOF) Then MM_offset = i  ' set MM_offset to the last possible record

End If
%>
<%
' *** Move To Record: if we dont know the record count, check the display range

If (MM_rsCount = -1) Then

 ' walk to the end of the display range for this page
 i = MM_offset
 While (Not MM_rs.EOF And (MM_size < 0 Or i < MM_offset + MM_size))
   MM_rs.MoveNext
   i = i + 1
 Wend

 ' if we walked off the end of the recordset, set MM_rsCount and MM_size
 If (MM_rs.EOF) Then
   MM_rsCount = i
   If (MM_size < 0 Or MM_size > MM_rsCount) Then MM_size = MM_rsCount
 End If

 ' if we walked off the end, set the offset based on page size
 If (MM_rs.EOF And Not MM_paramIsDefined) Then
   If (MM_offset > MM_rsCount - MM_size Or MM_offset = -1) Then
     If ((MM_rsCount Mod MM_size) > 0) Then
       MM_offset = MM_rsCount - (MM_rsCount Mod MM_size)
     Else
       MM_offset = MM_rsCount - MM_size
     End If
   End If
 End If

 ' reset the cursor to the beginning
 If (MM_rs.CursorType > 0) Then
   MM_rs.MoveFirst
 Else
   MM_rs.Requery
 End If

 ' move the cursor to the selected record
 i = 0
 While (Not MM_rs.EOF And i < MM_offset)
   MM_rs.MoveNext
   i = i + 1
 Wend
End If
%>
<%
' *** Move To Record: update recordset stats

' set the first and last displayed record
rimo_first = MM_offset + 1
rimo_last  = MM_offset + MM_size
If (MM_rsCount <> -1) Then
 If (rimo_first > MM_rsCount) Then rimo_first = MM_rsCount
 If (rimo_last > MM_rsCount) Then rimo_last = MM_rsCount
End If

' set the boolean used by hide region to check if we are on the last record
MM_atTotal = (MM_rsCount <> -1 And MM_offset + MM_size >= MM_rsCount)
%>
<%
' *** Go To Record and Move To Record: create strings for maintaining URL and Form parameters

' create the list of parameters which should not be maintained
MM_removeList = "&index="
If (MM_paramName <> "") Then MM_removeList = MM_removeList & "&" & MM_paramName & "="
MM_keepURL="":MM_keepForm="":MM_keepBoth="":MM_keepNone=""

' add the URL parameters to the MM_keepURL string
For Each Item In Request.QueryString
 NextItem = "&" & Item & "="
 If (InStr(1,MM_removeList,NextItem,1) = 0) Then
   MM_keepURL = MM_keepURL & NextItem & Server.URLencode(Request.QueryString(Item))
 End If
Next

' add the Form variables to the MM_keepForm string
For Each Item In Request.Form
 NextItem = "&" & Item & "="
 If (InStr(1,MM_removeList,NextItem,1) = 0) Then
   MM_keepForm = MM_keepForm & NextItem & Server.URLencode(Request.Form(Item))
 End If
Next

' create the Form + URL string and remove the intial '&' from each of the strings
MM_keepBoth = MM_keepURL & MM_keepForm
if (MM_keepBoth <> "") Then MM_keepBoth = Right(MM_keepBoth, Len(MM_keepBoth) - 1)
if (MM_keepURL <> "")  Then MM_keepURL  = Right(MM_keepURL, Len(MM_keepURL) - 1)
if (MM_keepForm <> "") Then MM_keepForm = Right(MM_keepForm, Len(MM_keepForm) - 1)

' a utility function used for adding additional parameters to these strings
Function MM_joinChar(firstItem)
 If (firstItem <> "") Then
   MM_joinChar = "&"
 Else
   MM_joinChar = ""
 End If
End Function
%>
<%
' *** Move To Record: set the strings for the first, last, next, and previous links

MM_keepMove = MM_keepBoth
MM_moveParam = "index"

' if the page has a repeated region, remove 'offset' from the maintained parameters
If (MM_size > 0) Then
 MM_moveParam = "offset"
 If (MM_keepMove <> "") Then
   params = Split(MM_keepMove, "&")
   MM_keepMove = ""
   For i = 0 To UBound(params)
     nextItem = Left(params(i), InStr(params(i),"=") - 1)
     If (StrComp(nextItem,MM_moveParam,1) <> 0) Then
       MM_keepMove = MM_keepMove & "&" & params(i)
     End If
   Next
   If (MM_keepMove <> "") Then
     MM_keepMove = Right(MM_keepMove, Len(MM_keepMove) - 1)
   End If
 End If
End If

' set the strings for the move to links
If (MM_keepMove <> "") Then MM_keepMove = MM_keepMove & "&"
urlStr = Request.ServerVariables("URL") & "?" & MM_keepMove & MM_moveParam & "="
MM_moveFirst = urlStr & "0"
MM_moveLast  = urlStr & "-1"
MM_moveNext  = urlStr & Cstr(MM_offset + MM_size)
prev = MM_offset - MM_size
If (prev < 0) Then prev = 0
MM_movePrev  = urlStr & Cstr(prev)
%>
<html>
<head>
<title>.:CMZB:.</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="masters.css" rel="stylesheet" type="text/css">
</head>

<body bgcolor="#005A97" style="background-image:url(imagens/f_f.jpg); background-repeat:repeat-x;">

<table width="900" align="center" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF">
 <tr> 
   <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
       <tr> 
         <td>


	<div align="center">

       <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="983" height="345" title="fachada">
             <param name="movie" value="imagens/fachada.swf">
             <param name="quality" value="high">
             <param name="wmode" value="opaque">
             <embed src="imagens/fachada.swf" quality="high" wmode="opaque" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="983" height="345"></embed>
           </object>

	</div>


	  </td>
       </tr>
       <tr>
         <td>



         <table width="100%" border="0" cellspacing="5" cellpadding="0" bgcolor="#FFFFFF">
             <tr> 
               <td width="58%" valign="top"> <table width="100%" border="0" cellpadding="0" cellspacing="4" bgcolor="#FFFFFF">
                   <tr> 

                   </tr>
                   <tr> 
                     <td><table width="100%" border="1" cellpadding="0" cellspacing="0" bgcolor="#CCCCCC">

                     <tr> 
                     <td><strong><font>  Listando 
                      [color="#FF0000"][b] <%=(rtipo.Fields.Item("Tipo").Value)%></font></strong></td>[/b][/color]
                   </tr>

                         <tr> 
                           <td>


                          <form name="form1" method="get" action="sessao.asp">
                                     <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                       <tr> 
                                         <td><strong>Pesquisar</strong><strong>                
                                                        
                                            Valor máximo</strong> 
                                         </td>
                                       </tr>
                                       <tr> 
                                         <td><strong>Tipo</strong> <select name="Cod_tipo" id="Cod_tipo">
                                             <%
While (NOT rimomostra.EOF)
%>
                                             <option value="<%=(rimomostra.Fields.Item("Cod_tipo").Value)%>" <%If (Not isNull((rtipo.Fields.Item("Cod_tipo").Value))) Then If (CStr(rimomostra.Fields.Item("Cod_tipo").Value) = CStr((rtipo.Fields.Item("Cod_tipo").Value))) Then Response.Write("SELECTED") : Response.Write("")%> ><%=(rimomostra.Fields.Item("Tipo").Value)%></option>
                                             <%
 rimomostra.MoveNext()
Wend
If (rimomostra.CursorType > 0) Then
 rimomostra.MoveFirst
Else
 rimomostra.Requery
End If
%>
                                           </select> <input name="Cod_sessao" type="hidden" id="Cod_sessao" value="25"> 
                                           <select name="valor" id="valor">
                                             <option value="30000" <%If (Not isNull(Request.QueryString("valor"))) Then If ("30000" = CStr(Request.QueryString("valor"))) Then Response.Write("SELECTED") : Response.Write("")%>>Até 
                                             R$ 30.000,00</option>
                                             <option value="60000" <%If (Not isNull(Request.QueryString("valor"))) Then If ("60000" = CStr(Request.QueryString("valor"))) Then Response.Write("SELECTED") : Response.Write("")%>>Até 
                                             R$ 60.000,00</option>
                                             <option value="100000" <%If (Not isNull(Request.QueryString("valor"))) Then If ("100000" = CStr(Request.QueryString("valor"))) Then Response.Write("SELECTED") : Response.Write("")%>>Até 
                                             R$ 100.000,00</option>
                                             <option value="250000" <%If (Not isNull(Request.QueryString("valor"))) Then If ("250000" = CStr(Request.QueryString("valor"))) Then Response.Write("SELECTED") : Response.Write("")%>>Até 
                                             R$ 250.000,00</option>
                                             <option value="500000" <%If (Not isNull(Request.QueryString("valor"))) Then If ("500000" = CStr(Request.QueryString("valor"))) Then Response.Write("SELECTED") : Response.Write("")%>>Até 
                                             R$ 500.000,00</option>
                                             <option value="100000000" <%If (Not isNull(Request.QueryString("valor"))) Then If ("100000000" = CStr(Request.QueryString("valor"))) Then Response.Write("SELECTED") : Response.Write("")%>>Listar 
                                             todos os imóveis</option>
                                           </select> <input type="submit" name="Submit" value="Buscar"></td>
                                       </tr>
                                     </table>
                                   </form>


                           </td>
                         </tr>
                       </table>
                       <strong><br>
                       Resultados (<%=(rimo_total)%>)</strong></td>
                   </tr>
                   <tr> 
                     <td> <table>
                         <%
startrw = 0
endrw = HLooper2__index
numberColumns = 4
numrows = 3
while((numrows <> 0) AND (Not rimo.EOF))
startrw = endrw + 1
endrw = endrw + numberColumns
%>
                         <tr align="center" valign="top"> 
                           <%
While ((startrw <= endrw) AND (Not rimo.EOF))
%>
                           <td> <table width="46%" height="104" border="1" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF" bgcolor="#FFFFFF" id="imo">
                               <tr> 
                                 <td><table width="100%" border="0" cellspacing="4" cellpadding="0">
                                     <tr> 
                                       <td><a href="detalhes.asp?cod_imovel=<%=(rimo.Fields.Item("cod_imovel").Value)%>&Cod_sessao=<%=(rimo.Fields.Item("Cod_sessao").Value)%>&Cod_tipo=<%=(rimo.Fields.Item("Cod_tipo").Value)%>&Cod_cidade=<%=(rimo.Fields.Item("Cod_cidade").Value)%>"><img src="imoveis/<%=(rimo.Fields.Item("imagem").Value)%>" width="179" height="136" border="0"></a></td>
                                     </tr>
                                     <tr> 
                                       <td><strong><%=(rtipo.Fields.Item("Tipo").Value)%></strong></td>
                                     </tr>
                                     <tr> 
                                       <td>Valor: <strong><font color="#FF0000"><%= FormatCurrency((rimo.Fields.Item("valor").Value), 2, -2, -2, -2) %></font></strong></td>
                                     </tr>
                                     <tr> 
                                       <td>Bairro: <strong><%=(rimo.Fields.Item("Bairro").Value)%></strong></td>
                                     </tr>

                                   </table></td>
                               </tr>
                             </table></td>
                           <%
startrw = startrw + 1
rimo.MoveNext()
Wend
%>
                         </tr>
                         <%
numrows=numrows-1
Wend
%>
                       </table></td>
                   </tr>
                   <tr> 
                     <td> <div align="center"> <strong> Páginas 
                         <%
TM_counter = 0
For i = 1 to rimo_total Step MM_size
TM_counter = TM_counter + 1
TM_PageEndCount = i + MM_size - 1
if TM_PageEndCount > rimo_total Then TM_PageEndCount = rimo_total
if i <> MM_offset + 1 then
Response.Write("<a href=""" & Request.ServerVariables("URL") & "?" & MM_keepMove & "offset=" & i-1 & """>")
Response.Write(TM_counter & "</a>")
else
Response.Write("<b>" & TM_counter & "</b>")
End if
if(TM_PageEndCount <> rimo_total) then Response.Write(" ")
next
%>
                         </strong> </div></td>
                   </tr>
                 </table></td>
             </tr>
           </table></td>
       </tr>
     </table></td>
 </tr>
 <tr>
   <td>
   <img src="imagens/rodape.png">
   </td>


 </tr>
</table>
</body>
</html>
<%
rimo.Close()
Set rimo = Nothing
%>
<%
rdst.Close()
Set rdst = Nothing
%>
<%
rimomostra.Close()
Set rimomostra = Nothing
%>
<%
rtipo.Close()
Set rtipo = Nothing
%>

 

Grifei em vermelho a linha 373 que esta dando erro.

Compartilhar este post


Link para o post
Compartilhar em outros sites

Tente criar os proprios codigos não deixe o DW dominar fica muito sujo o codigo

 

Bom quanto ao erro ele ta dizendo que o campo que voce está tentando exibir não foi selecionado ou não trouxe nenhum registro

 

Precisa tratar para evitar este erro

Compartilhar este post


Link para o post
Compartilhar em outros sites

Na verdade eu já peguei este script pronto, só estou adaptando. Eu já mexo com PHP, porem ASP eu nunca havia mexido.

 

Alguém com mais conhecimento pode me ajudar a resolver isso?

 

Obrigado

Compartilhar este post


Link para o post
Compartilhar em outros sites

Mas eu já disse qual o provável problema

 

não pode mandar exibir algo que não tem certeza que foi selecionado antes

Compartilhar este post


Link para o post
Compartilhar em outros sites

Como eu posso tratar este pedaço abaixo? Pelo que eu vi, é aqui que faz o select e na hora que mandar exibir da o problema.

 

 

ESTE É O SELECT

 

<%

Dim rimomostra

Dim rimomostra_numRows

 

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

rimomostra.ActiveConnection = MM_dados_STRING

rimomostra.Source = "SELECT * FROM Tipo ORDER BY Tipo ASC"

rimomostra.CursorType = 0

rimomostra.CursorLocation = 2

rimomostra.LockType = 1

rimomostra.Open()

 

rimomostra_numRows = 0

%>

 

 

ESTE MOSTRA

 

<tr>

<td><strong><%=(rtipo.Fields.Item("Tipo").Value)%></strong></td>

</tr>

Compartilhar este post


Link para o post
Compartilhar em outros sites

Existe este campo tipo dentro da tabela tipo?

Compartilhar este post


Link para o post
Compartilhar em outros sites

Voltando ao seu codigo

 

Obviamente sugiro fortemente que tente fazer os seus proprios codigos posteriormente mas por hora deve tratar o que imprimirá vindo do banco

 

No seu caso seria algo como

 

<%
Dim rimomostra
Dim rimomostra_numRows

Set rimomostra = Server.CreateObject("ADODB.Recordset")
rimomostra.ActiveConnection = MM_dados_STRING
rimomostra.Source = "SELECT * FROM Tipo ORDER BY Tipo ASC"
rimomostra.CursorType = 0
rimomostra.CursorLocation = 2
rimomostra.LockType = 1
rimomostra.Open()

rimomostra_numRows = 0
%>

 

Caso seja um único registro

 

IF NOT rimomostra.EOF THEN
<tr>
<td><strong><%=(rtipo.Fields.Item("Tipo").Value)%></strong></td>
</tr> 
End If

 

Caso seja um laço de repetição

 

WHILE NOT rimomostra.EOF
<tr>
<td><strong><%=(rtipo.Fields.Item("Tipo").Value)%></strong></td>
</tr> 
rimomostra.MOVENEXT
WEND

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.