Ir para conteúdo

POWERED BY:

Arquivado

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

Radiske

Erro em SQL ADODB.Recordset error '800a0cc1'

Recommended Posts

Pessoal, estou me deparando com o seguinte erro ao fazer uma pesquisa no bd.

Não sei mais o que fazer, ja tentei de tudo.

 

ADODB.Recordset error '800a0cc1'

 

Item cannot be found in the collection corresponding to the requested name or ordinal.

 

/servicos/estatisticas/postal/analises/SomaEve2.asp, line 145

 

A linha 145 seria essa:

 

col(x)=SX.Fields(x).name

 

 

O código completo da página

 

<html>

<head>
<meta http-equiv="Content-Language" content="pt-br">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Relatório Geral - Sistema de Informação Policial</title>
</head>
<BODY background="../../../../images/quadrim.gif" bgcolor="#FFFFFF">

<%
Ano = Request("AnoIni")
VOpano= Request("Ano")
Municipio= Request("Municipio")
Semestre= Request("AnoSem")
Fato=Request("Fato")
Taxa=Request("Taxa")
Municipio="'"+Replace(Municipio,", ","','")+"'"
Fato="'"+Replace(Fato,", ","','")+"'"
if municipio="" then
  Tmunicipio="RS"
else 
  Tmunicipio=municipio
end if
TAno=Ano
if semestre<>"" then
  TAno=Ano+" / "+semestre
end if  

if ano<>"" Then
'response.Write(Municipio)
'response.Write(Fato)

%>
<table border="0" bgcolor="" align="center" cellpadding="0" cellspacing="0">
  <tr> 
	<td align="left" valign="top"> 
	  <div align="center">
	  <center>
		  <table width="100%" border="0" cellpadding="8" cellspacing="0" bgcolor="#00FF00">
			<tr bgcolor="2F8741"> 
			  <td align="center"><b><font size="2" face="Arial, Helvetica, sans-serif" color="#FFFFFF">Sistema 
				de Informação Policial (Consumados)<br>
				  
				<% if Vopano<>1 then %>
				Ano de <%=TAno%> 
				<% else %>
				Série Anual  <%=semestre%>
				<%end if%>
				<br>
				<%=Tmunicipio%></font></b></td>
			</tr>
		  </table>
		</center>
<%
	  If (MesIni = "Janeiro") Then
		   MesIni = "01"
	  Else If (MesIni = "Fevereiro") Then
		   MesIni = "02"
	  Else If (MesIni = "Março") Then
		   MesIni = "03"
	  Else If (MesIni = "Abril") Then
		   MesIni = "04"
	  Else If (MesIni = "Maio") Then
		   MesIni = "05"
	  Else If (MesIni = "Junho") Then
		   MesIni = "06"
	  Else If (MesIni = "Julho") Then
		   MesIni = "07"
	  Else If (MesIni = "Agosto") Then
		   MesIni = "08"
	  Else If (MesIni = "Setembro") Then
		   MesIni = "09"
	  Else If (MesIni = "Outubro") Then
		   MesIni = "10"
	  Else If (MesIni = "Novembro") Then
		   MesIni = "11"
	  Else If (MesIni = "Dezembro") Then
		   MesIni = "12"
	  End If
	  End If
	  End If
	  End If
	  End If
	  End If
	  End If
	  End If
	  End If
	  End If
	  End If
	  End If

'TRANSFORM Sum(FatoMesAno.Total) AS Qtd
'SELECT Municipios.Nom_Mun, Fato.desc_fato AS Fato
'FROM Municipios INNER JOIN ((fatopub INNER JOIN Fato ON fatopub.codpub = Fato.codpub) INNER JOIN FatoMesAno ON Fato.fatocompl = FatoMesAno.compfato) ON Municipios.CEP = FatoMesAno.CEP
'WHERE (((Fato.desc_fato) In ('FURTO PUNGA','FURTO QUALIFICADO ')) AND ((FatoMesAno.ano)=2003) AND ((Municipios.Nom_Mun) In ('Osório','Parobé')))
'GROUP BY FatoMesAno.ano, Municipios.Nom_Mun, Fato.desc_fato
'ORDER BY Fato.desc_fato
'PIVOT FatoMesAno.mes;


sql= " TRANSFORM Sum(FatoMesAno.Total) AS QtdCol " 
sql=sql+" SELECT Fato.desc_fato AS Fato, Municipios.Nom_Mun As Município, Pop" 
sql=sql+" FROM Municipios INNER JOIN ((fatopub INNER JOIN Fato ON fatopub.codpub = Fato.codpub) INNER JOIN FatoMesAno ON Fato.fatocompl = FatoMesAno.compfato) ON Municipios.CEP = FatoMesAno.CEP " &_
	 " WHERE  ((Fato.desc_fato) In ("&Fato&"))"
	 if municipio<>"" then
		if municipio="Interior" then
			 SQL=SQL+"AND (Municipios.cep NOT IN (95840000,94800000,94900000," &_
					 "92990000,94380000,94000000," &_
			 		 "92500000,94400000,90000000))"
		   else if municipio="Grande PoA" then
					 SQL=SQL+"AND (Municipios.cep IN (95840000,94800000,94900000," &_
					 "92990000,94380000,94000000," &_
			 		 "92500000,94400000,90000000))"
		   else
				sql=sql+" AND ((Municipios.Nom_Mun) In ("&Municipio&"))"
		   end if
		end if
	 end if
	if VOpano<>1 then
	   SQL=SQL+ " AND (((FatoMesAno.ano)="+ano+")) "
	 end if  
	 if semestre="1ºSem" then
		SQL=SQL+" AND (FatoMesAno.mes>=1 AND FatoMesAno.mes<=6)"
	 end if
	 if semestre="2ºSem" then
		SQL=SQL+" AND (FatoMesAno.mes>=7 AND FatoMesAno.mes<=12)"
	 end if
	 
	 SQL=SQL+" GROUP BY Fato.desc_fato, Municipios.Nom_Mun, pop"

	 if VOpano<>1 then
		sql=sql+" PIVOT FatoMesAno.mes; " 
	 else
		sql=sql+" PIVOT FatoMesAno.ano; " 
	 end if   
	 
' 	 Response.Write "<br>" & sql & "</br>"
	 
		Set CX = Server.CreateObject("ADODB.Connection")
		CX.Open "Teste"
		Set SX = CX.Execute(SQL)
	   Dim col(32) 
	   x=0
	   Do While x <= 32
		  col(x)=SX.Fields(x).name
		  if col(x)="PubFato" then col(x)="Grupo"
		  if col(x)="1" then col(x)="Jan"
		  if col(x)="2" then col(x)="Fev"
		  if col(x)="3" then col(x)="Mar"
		  if col(x)="4" then col(x)="Abr"
		  if col(x)="5" then col(x)="Mai"
		  if col(x)="6" then col(x)="Jun"
		  if col(x)="7" then col(x)="Jul"
		  if col(x)="8" then col(x)="Ago"
		  if col(x)="9" then col(x)="Set"
		  if col(x)="10" then col(x)="Out"
		  if col(x)="11" then col(x)="Nov"
		  if col(x)="12" then col(x)="Dez"
		  if err.number<>0 then
			err.number=0 
			exit do
		  end if
		  x=x+1
	   Loop
		x=x-1
	'	 response.write sql 
		if ((SX.EOF) And (SX.BOF)) Then					
		  %>
	 	<p align="center"><b><font size="2" face="Arial Black" color="#000000">Não há eventos</font></b></p>
		  <%
		Else
		DIM QtdCol(500,17)
		%>
		<div align="center">
		  <table border="1" cellpadding="2" cellspacing="0">
			<tr valign="middle"> 
			  <td align="center" bgcolor="#C0C0C0"> <font face="Verdana, Arial, Helvetica, sans-serif"><b><font size="1">Nr</font></b> 
				</font></td>
			  <%
			For cab=0 to x 
			  if col(cab)<>"Pop" then %>
			  <td bgcolor="#C0C0C0"> <div align="center"><font face="Verdana, Arial, Helvetica, sans-serif"><b><font size="1"><%= col(cab)%></font></b> </font></div></td>
			  <%
			  end if 
			Next
			  %>
			  <td align="left" bgcolor="#C0C0C0"> <div align="center"><font face="Verdana, Arial, Helvetica, sans-serif"><b><font size="1">Tot</font></b> 
				  </font></div></td>
				 <% if Vopano<>1 then %>
			  <td align="center" bgcolor="#C0C0C0"> <font face="Verdana, Arial, Helvetica, sans-serif"><b><font size="1">Tx*</font></b> 
				  </td>
				 <% end if%>
				  
			</tr>
			<% 
		SX.MoveFirst
		Cont=1
		corF=0
	   tcor="#DFDFDF"
	   tmpFato=SX.Fields("fato")
		Fatcor="#FFFFFF"
		Do While (not SX.EOF)
		if  SX.Fields("fato")<>tmpFato then
			tmpFato=SX.Fields("fato")
		  if corF=1 then
			  Fatcor="#FFFFFF" 
			  corF=0
		  else 
			  Fatcor="#DFDFDF"
			  corF=1
		  end if	  
		end if

%>
			<tr> 
			  <td bgcolor=<%=Fatcor%>> 
				<div align="center"><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><%=Cont%></font></div></td>
			  <%
			  Tot=0
			  For val=0 to x
				if col(val)<>"Pop" then
			  %>
			  <td bgcolor=<%=Fatcor%>>
			   <% if col(val)="Fato" or col(val)="Município" then %> 
				<div align="left">
				<% else %>
				<div align="right">
				<% end if
					if Sx.Fields(val)>0 then
				%>
				<font size="1" face="Verdana, Arial, Helvetica, sans-serif"><%=SX.Fields(val)%></font></div>
			   </div>
			  </td>
			  <%
				   else
				%>
				<font size="1" face="Verdana, Arial, Helvetica, sans-serif">  </font>
			  <%
				   end if
				if SX.Fields(val)<>"" and col(val)<>"Fato" and col(val)<>"Município" and col(val)<>"Pop" then
				  Tot=Tot+SX.Fields(val)
				  QtdCol(1,val)=QtdCol(1,val)+Cint(SX.Fields(val))			  
				end if
			   else
				   vpop=SX.Fields(val) 
			   end if 
			  Next
			  %>
			  <td bgcolor=<%=Fatcor%>> 
				<div align="center"><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><%=Tot%></font></div>
			  </td>
			  <td bgcolor=<%=Fatcor%>> 
				<%
				Select Case Taxa
					Case 1
					   vTx= 300000
					Case 2
					   vTx= 200000
					Case 3
					   vTx= 100000
					Case 4
					   vTx= 50000
					Case 5
					   vTx= 10000
				End Select		 
				tx=(Tot/vpop)*vTx

					if Vopano<>1 then
				%>
				<div align="right"><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><%=FormatNumber(tx,2)%></font></div>
				<%end if%>
			  </td>
			</tr>
			<%
		  if cor=1 then
			 cor=0
			 tcor="#FFFFFF"
		  else if cor=0 then
				  cor=1
				  tcor="#DFDFDF"
			  end if
		  end if	
	   Cont=Cont+1

	 SX.MoveNext

	Loop
  
%>
			<tr valign="middle"> 
			  <td colspan="2" align="center" bgcolor="#C0C0C0"><font size="1" face="Verdana, Arial, Helvetica, sans-serif"> 
				Total </font></td>
			  <%
			  For n=2 to x
			  %>
			  <td bgcolor="#C0C0C0"> <div align="center"><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><%=QtdCol(1,n)%> </font></div></td>
			  <%
			   TotGer=QtdCol(1,n)+TotGer
			  Next
			  %>
			  <td bgcolor="#C0C0C0"> <div align="center"><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><%=TotGer%> </font></div></td>
   				 <% if Vopano<>1 then
   					x=x+1 
				 %>
				<td bgcolor="#C0C0C0"> <div align="center"><font size="1" face="Verdana, Arial, Helvetica, sans-serif"> </font></div></td>
				<%  end if%>

			</tr>
			<tr bgcolor=<%=tcor%>> 
			  <td Colspan=<%=x+2%>> 
				<p align="center"> <A HREF="Somaeve2.asp">[nova consulta]</A> 
				</p></td>
			</tr>
		  </table>
		   <% if Vopano<>1 then
		   		Select Case Taxa
					Case 1
					   LTx="300.000"
					Case 2
					   LTx= "200.000"
					Case 3
					   LTx= "100.000"					   
					Case 4
					   LTx= "50.000"
					Case 5
					   LTx= "10.000"
				End Select		 
		   
			%>
		  <div align="left"><b><font size="1"  face="Arial, Helvetica, sans-serif">
		  
		  * Tx = Taxa por <%=Ltx%> hab.</b></font></div>
		  <% end if
  End if		  
		  %>
		</div>
	  </div>
	</td>
  </tr>
</table>
<%
Else
%>
<table border="0" width="100%" height="100%">
  <tr>
	<td width="100%">
	  <form method="POST" action="SomaEve2.asp">
		<div align="center">
		  <center>
			<table border="0" cellpadding="8" bgcolor="#FFFFFF" cellspacing="0">
			  <tr> 
				<td colspan="2" align="center" bgcolor="#008000"><b><font color="#FFFFFF" size="3" face="Geneva, Arial, Helvetica, san-serif">Consulta 
				  de Fatos</font></b></td>
			  </tr>
			  <tr> 
				<td align="left" bgcolor="#336699" ><b><font color="#FFFFFF" size="1" face="Arial, Helvetica, sans-serif">Selecione 
				  o(s) Município(s):</font></b></td>
				<td align="left" bgcolor="#336699" ><font color="#FFFFFF"><b><font size="1" face="Arial, Helvetica, sans-serif">Selecione 
				  o(s) Fato(s):</font></b></font></td>
			  </tr>
			  <% 
					Set CX = Server.CreateObject("ADODB.Connection")
					CX.Open "Teste"
				 
					Set SX = CX.Execute(" SELECT Municipios.Cod_Mun, Municipios.Nom_Mun " &_
				 							" FROM Municipios " &_
				 							" ORDER BY Municipios.Nom_Mun") 
					SX.MoveFirst
				 %>
			  <tr> 
				<td  align="center" valign="top" bgcolor="#336699" > <div align="left"><font size="6" face="Arial"> 
					<select name="Municipio" size="10" multiple>
					  <% 
					Do While not SX.EOF %>
					  <option> <%= SX.Fields("Nom_Mun") %> </option>
					  <%
						SX.MoveNext 
				   Loop
				   %>
					</select>
					</font> </div></td>
				<td  align="center" bgcolor="#336699" > <% 
					Set CX = Server.CreateObject("ADODB.Connection")
					CX.Open "Teste"
					Set SX = CX.Execute(" SELECT Fato.[desc_fato] as Fato " &_
				 							" FROM Fato " &_
				 							" ORDER BY Fato.[desc_fato]") 
					SX.MoveFirst
				 %> <select name="Fato" size="10" multiple style="font-family: Arial; font-size: 8pt">
					<% 
					Do While not SX.EOF %>
					<option> <%= SX.Fields("Fato") %> </option>
					<%
						SX.MoveNext 
				   Loop
				   %>
				  </select></td>
			  </tr>
			  <tr> 
				<td colspan="2" align="left" bgcolor="#336699" ><div align="left"></div></td>
			  </tr>
			  <tr> 
				<td align="left" bgcolor="#336699" ><font color="#FFFFFF"><b><font size="2" face="Arial, Helvetica, sans-serif">Selecione 
				  o ano:</font></b></font> <select name="AnoIni" size="1" >
					<option>1997</option>
					<option>1998</option>
					<option>1999</option>
					<option>2000</option>
					<option>2001</option>
					<option>2002</option>
					<option>2003</option>
					<option>2004</option>
					<option>2005</option>
					<option>2006</option>
					<option>2007</option>
				  </select> <select name="Anosem" size="1" >
					<option></option>
					<option>1ºSem</option>
					<option>2ºSem</option>
				  </select> <input type="checkbox" name="ano" value="1"> <font face="Arial" size="1" color="#FFFFFF">Série 
				  anual</font> <font color="#FFFFFF" size="1" face="Arial, Helvetica, sans-serif"><br>
				  </font></td>
				<td align="left" bgcolor="#336699" ><div align="right"><font color="#FFFFFF" size="1" face="Arial, Helvetica, sans-serif">Taxa 
					por</font> 
					<select name="Taxa" size="1" id="Taxa">
					  <option value="1" >300.000</option>
					  <option value="2">200.000</option>
					  <option value="3" selected>100.000</option>					  
					  <option value="4">50.000</option>
					  <option value="5">10.000</option>
					</select>
					<font color="#FFFFFF" size="1" face="Arial, Helvetica, sans-serif">hab.</font> </div></td>
			  </tr>
			  <tr> 
				<td colspan="2" bgcolor="#C0C0C0"> <p align="center"> 
					<input type="submit" value="Consultar" name="B1">
				  </p></td>
			  </tr>
			</table>
		  <p> </p></center>
		   
		</div>
	  </form>
	</td>
  </tr>
</table>
<%end if%>
</body>

Compartilhar este post


Link para o post
Compartilhar em outros sites

veja se todos os campso estao digitados corretamente

Compartilhar este post


Link para o post
Compartilhar em outros sites

Ja procurei e os campos estão certos, talvez seja um problema nesse while, alguém poderia estabelecer uma solução sem ser com o While? Estou começando ainda =/

Compartilhar este post


Link para o post
Compartilhar em outros sites

Eu do um response.write sx.fields(x).name e aparece

 

FatoMunicípioPop145

 

Sou noob em ASP, se alguém puder resolver pra mim, agradeço desde já

Compartilhar este post


Link para o post
Compartilhar em outros sites

Ninguém? Meu trabalho depende disso, me colocaram de Webdesigner porque o cara saiu fora, meu conhecimento é pouco =/

 

Eu trabalhava com redes... =|

Compartilhar este post


Link para o post
Compartilhar em outros sites

Faça assim:

 

i = 0
while i < rs.fields.count 
response.write (Rs.Fields(i).name & "<br>")
i = i + 1
wend

Dentro do while você precisa especificar o numero CORRETO de campos, se nao ele da esse pau...

 

PS: Segundo a regra numero 10 do nosso forum, não é permitido ficar dando "ups" no tópico....

 

Abraços...

Compartilhar este post


Link para o post
Compartilhar em outros sites

Arrumei o While, agora aparece o seguinte erro:

 

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

 

Tipos incompatíveis: '[string: "RIXA"]'

 

/servicos/estatisticas/postal/analises/SomaEve2.asp, line 229

 

A linha 229 é essa

 

if Sx.Fields(val)>0 then

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.