Ir para conteúdo

POWERED BY:

Arquivado

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

Boris

Problema com campo valor

Recommended Posts

Galera estou com problema no sistema de busca.

 

Não consigo pegar o registro a partir de um valor minimo

 

Não me aparece erro algum apenas diz que o valor nõa foi encontrado

 

o codigo que tenho é o seguinte :

 

buscar.asp

<body bgcolor="#0000CC" text="#000000" topmargin="52">
<FORM  method="get" action="buscar.asp">
  <table border="0" cellspacing="0" cellpadding="2" align="center" bordercolor="#000000" width="700">
	<tr>
	  <td bgcolor="#000000"><table width="700" border="0" align="center" cellpadding="0" cellspacing="0">
		<tr>
		  <td background="../../modelo2/img/topo.jpg"><img src="Imagens/topo.gif" width="700" height="87" border="0" usemap="#Map">
			  <map name="Map">
				<area shape="rect" coords="633,17,693,75" href="../email.asp">
				<area shape="rect" coords="541,17,625,77" href="../encomenda.asp">
				<area shape="rect" coords="448,17,532,77" href="../cadastro.asp">
				<area shape="rect" coords="359,17,443,77" href="../empresa.asp">
				<area shape="rect" coords="273,17,357,77" href="../index.asp">
			</map></td>
		</tr>
		<tr>
		  <td height="10" align="center" valign="top" bgcolor="#FFFFFF"><table width="700" border="0" align="center" cellpadding="0" cellspacing="0">
			  <tr>
				<td height="27" align="center" valign="middle" background="Imagens/line_fundo.jpg"><table width="100%" border="0" cellspacing="0" cellpadding="0">
					<tr>
					  <td height="27"><table width="100%" height="24" border="0" cellspacing="2">
						  <tr align=center class=texto>
							<td width="23%" height="20"><div align="right"><span class="style30"><font face="Verdana, Arial, Helvetica, sans-serif">Tipo</font></span><span class="style1"><font face="Verdana, Arial, Helvetica, sans-serif">
								<% 
tp_imovel = Request.Form("tp_imovel")	
desc_aluguel = Request.form("desc_aluguel")
referencia = Request.form("referencia")


strQ = "SELECT * FROM tipo_imovel WHERE desc_aluguel = 'desc_aluguel' AND referencia = 'referência'" 
strQ = "SELECT * FROM tipo_imovel WHERE tp_imovel IS NOT NULL"
Set objRS = cn.Execute(strQ)

Response.Write "<SELECT  class='cx' NAME='tp_imovel'>"
Response.Write " <option value='0'>Selecione</option>"

If Not objRS.EOF Then
  While Not objRS.EOF
	Response.Write "<OPTION VALUE='" & objRS("tp_imovel") & "'"
	If Request("id_tp_imovel") = objRS("tp_imovel") Then Response.Write " selected"
	Response.Write ">" & objRS("tp_imovel") & "</OPTION>"
	objRS.MoveNext
  Wend
End If

Response.Write "</SELECT>"

set objRS = Nothing
%>
							</font></span></div></td>
							<td width="13%"><div align="right"><font face="Verdana, Arial, Helvetica, sans-serif"><span class="style1">
								<select  name="desc_aluguel" size="1" class="cx" id="desc_aluguel">
								  <option value="0" selected>Selecione</option>
								  <option value="Aluguel">Aluguel</option>
								  <option value="Venda">Venda</option>
								</select>
							</span></font></div></td>
							<td width="19%"><div align="right"> <span class="style30"><font face="Verdana, Arial, Helvetica, sans-serif">Ref.:</font></span><strong><font face="Verdana, Arial, Helvetica, sans-serif">
								<% 

strQ = "SELECT * FROM imovel WHERE referencia = 'referencia' AND ativo = '1'" 
strQ = "SELECT * FROM imovel WHERE referencia IS NOT NULL"
Set objRS = cn.Execute(strQ)

Response.Write "<SELECT  class='cx' NAME='referencia'>"
Response.Write " <option value='0'>Selecione</option>"

If Not objRS.EOF Then
  While Not objRS.EOF
	Response.Write "<OPTION VALUE='" & objRS("referencia") & "'"
	If Request("id_imovel") = objRS("referencia") Then Response.Write " selected"
	Response.Write ">" & objRS("referencia") & "</OPTION>"
	objRS.MoveNext
  Wend
End If

Response.Write "</SELECT>"

set objRS = Nothing
%>
							</font></strong></div></td>
							<td width="16%" height="23"><div align="right"><span class="style2"><font color="#000000" face="Verdana, Arial, Helvetica, sans-serif">
							  <select size="1" name="valor_minimo" class="cx">
								<option value="0">Valor Mínimo</option>
								<option value="5000">R$ 50.00</option>
								<option value="20000">R$ 200.00</option>
								<option value="50000">R$ 50.000</option>
								<option value="100000">R$ 100.000</option>
								<option value="150000">R$ 150.000</option>
								<option value="200000">R$ 200.000</option>
								<option value="250000">R$ 250.000</option>
								<option value="300000">R$ 300.000</option>
								<option value="350000">R$ 350.000</option>
								<option value="400000">R$ 400.000</option>
								<option value="450000">R$ 450.000</option>
							  </select>
							</font></span></div></td>
							<td width="19%"><span class="style2"><font color="#000000" face="Verdana, Arial, Helvetica, sans-serif"><font color="#000000" face="Verdana, Arial, Helvetica, sans-serif">
							  <select size="1" name="valor_maximo" class="cx">
								<option value="1000000">Valor Máximo</option>
								<option value="50000">R$ 50.000</option>
								<option value="100000">R$ 100.000</option>
								<option value="150000">R$ 150.000</option>
								<option value="200000">R$ 200.000</option>
								<option value="250000">R$ 250.000</option>
								<option value="300000">R$ 300.000</option>
								<option value="350000">R$ 350.000</option>
								<option value="400000">R$ 400.000</option>
								<option value="450000">R$ 450.000</option>
								<option value="500000">R$ 500.000</option>
							  </select>
							</font></font></span></td>
							<td width="10%"><div align="left"><strong><font color="#000000" face="Verdana, Arial, Helvetica, sans-serif">
								<input type="image" src=Imagens/buscar.jpg align=absmiddle style="font-family=Tahoma; font size=10" id=image12 name=image1>
							</font></strong></div></td>
						</table></td>
					</tr>
				</table></td>
			  </tr>
			</table>
			  <span class="style31"><br>
				Resultado da Busca </span><br>
			<table width="700" border="0" align="center" cellpadding="0" cellspacing="0">
			  <tr>
				<td height="207" valign="top" bgcolor="#FFFFFF"><font face="Comic Sans MS">  </font>
			  <table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
				<tr>
				  <td><table width="98%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#F7F7F7">
					  <tr>
						<td><table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#0000CC">
							<tr>
							  <td width="20%" height="22" class="cx"><div align="center" class="style47">Referência</div></td>
							  <td width="22%" class="cx"><div align="center" class="style47">Bairro</div></td>
							  <td width="16%" class="cx"><div align="center" class="style47">Dormitórios</div></td>
							  <td width="17%" class="cx"><div align="center" class="style47">Vagas</div></td>
							  <td width="25%" class="cx"><div align="center" class="style47">Preço</div></td>
							</tr>
						</table></td>
					  </tr>
					  <tr>
						<td valign="top"><%									  

If Trim( Request.Form("tp_imovel")) <> "" AND Trim( Request.Form("desc_aluguel")) = "0"  AND Trim( Request.Form ("referencia"))= "0" Then

	comandosql = "SELECT tp_imovel FROM imovel WHERE (((tp_imovel) Like '*')) and ativo = '1' ORDER BY nivel_prioridade ASC"

	comandosql = "SELECT * FROM imovel "

	comandosql = comandosql & " Where tp_imovel Like '%" & Request("tp_imovel") & "%' AND ativo = '1'ORDER BY nivel_prioridade ASC"

'############################################################################
#######################
	Set conexao =  Server.CreateObject("ADODB.Connection")
	conexao.Open "DBQ=" & Server.MapPath("..\bd\bd.mdb") & ";Driver={Microsoft Access Driver (*.mdb)}"
	Set consulta = conexao.Execute(comandosql)
'############################################################################
#######################

		total = 0
		while not consulta.EOF
			total = total + 1
			consulta.MoveNext
		wend

		if total > 0 then
		consulta.MoveFirst


	%>
						  <table border="0" width="100%" cellspacing="1">
							<%

	while not consulta.EOF

	n = consulta("id_imovel")
	%>
							<tr>
							  <td width="20%" height="20" bgcolor="#F7F7F7" class="style39"><div align="center" class="style36"><a href="ve_imovel.asp?id_imovel=<%=consulta("id_imovel")%>" style="text-decoration:none; color:#666666">
								<% =consulta("referencia") %>
								</a> </div></td>
								  <td width="22%" bgcolor="#F7F7F7" class="style39"><div align="center" class="style36"><a href="ve_imovel.asp?id_imovel=<%=consulta("id_imovel")%>" style="text-decoration:none; color:#666666">
									<% =consulta("bairro") %>
									</a></div></td>
								  <td width="16%" bgcolor="#F7F7F7" class="style39"><div align="center" class="style36">
									<% =consulta("dormitorios") %>
									</div></td>
								  <td width="17%" bgcolor="#F7F7F7" class="style39"><div align="center" class="style36">
									<% =consulta("vagas") %>
									</div></td>
								  <td bgcolor="#F7F7F7" class="style39"><div align="right" class="style36">
									<div align="center">R$
									  <% =consulta("valor") %>
									  </div>
								  </div></td>
								</tr>
							<%

	consulta.MoveNext
	WEnd

	%>
							</table>
							<%
	end if
	'fechaconexao
	conexao.close
	Set conexao = Nothing
	end if	
%>
							<%									  

If Trim( Request.Form("tp_imovel")) <> "" AND Trim( Request.Form("desc_aluguel")) <> ""  AND Trim( Request.Form ("referencia"))= "0" Then

	comandosql = "SELECT * FROM imovel WHERE (((tp_imovel) Like '*')) AND ((desc_aluguel) Like '*') and ativo = '1' ORDER BY nivel_prioridade ASC"

	comandosql = "SELECT * FROM imovel "

	comandosql = comandosql & " Where tp_imovel Like '%" & Request("tp_imovel") & "%' AND desc_aluguel Like '%" & Request("desc_aluguel") & "%' AND ativo = '1' ORDER BY nivel_prioridade ASC"


	Set conexao =  Server.CreateObject("ADODB.Connection")
	conexao.Open "DBQ=" & Server.MapPath("..\bd\bd.mdb") & ";Driver={Microsoft Access Driver (*.mdb)}"
	Set consulta = conexao.Execute(comandosql)

		total = 0
		while not consulta.EOF
			total = total + 1
			consulta.MoveNext
		wend

		if total > 0 then
		consulta.MoveFirst


	%>
							<table border="0" width="100%" cellspacing="1">
							<%

	while not consulta.EOF

	n = consulta("id_imovel")
	%>
							<tr>
							  <td width="20%" height="20" bgcolor="#F7F7F7" class="style39"><div align="center" class="style36"><a href="ve_imovel.asp?id_imovel=<%=consulta("id_imovel")%>" style="text-decoration:none; color:#666666">
								<% =consulta("referencia") %>
								</a> </div></td>
									<td width="22%" bgcolor="#F7F7F7" class="style39"><div align="center" class="style36"><a href="ve_imovel.asp?id_imovel=<%=consulta("id_imovel")%>" style="text-decoration:none; color:#666666">
									  <% =consulta("bairro") %>
									  </a></div></td>
									<td width="16%" bgcolor="#F7F7F7" class="style39"><div align="center" class="style36">
									  <% =consulta("dormitorios") %>
									  </div></td>
									<td width="17%" bgcolor="#F7F7F7" class="style39"><div align="center" class="style36">
									  <% =consulta("vagas") %>
									  </div></td>
									<td bgcolor="#F7F7F7" class="style39"><div align="right" class="style36">
									  <div align="center">R$
										<% =consulta("valor") %>
										</div>
									</div></td>
								  </tr>
							<%

	consulta.MoveNext
	WEnd

	%>
							</table>
							  <%
	end if
	'fechaconexao
	conexao.close
	Set conexao = Nothing
	end if	
%>
							  <%

If Trim( Request.Form("tp_imovel") ) <> "" AND Trim( Request.Form("desc_aluguel")) <> "" AND Trim ( Request.Form("referencia"))<>""Then

		comandosql = "SELECT * FROM imovel WHERE (((tp_imovel) Like '*')) AND ((desc_aluguel) Like '*') AND ((referencia) Like '*') AND ativo = '1' ORDER BY nivel_prioridade ASC"

		comandosql = "SELECT * FROM imovel "

		comandosql = comandosql & " Where tp_imovel Like '%" & Request("tp_imovel") & "%' AND desc_aluguel Like '%" & Request("desc_aluguel") & "%' AND referencia Like '%" & Request("referencia") & "%' AND ativo = '1' ORDER BY nivel_prioridade ASC"

'############################################################################
#################################
		Set conexao =  Server.CreateObject("ADODB.Connection")
		conexao.Open "DBQ=" & Server.MapPath("..\bd\bd.mdb") & ";Driver={Microsoft Access Driver (*.mdb)}"
		Set consulta = conexao.Execute(comandosql)
'############################################################################
#################################

			total = 0
		while not consulta.EOF
			total = total + 1
			consulta.MoveNext
		wend

		if total > 0 then
		consulta.MoveFirst


%>
							  <table border="0" width="100%" cellspacing="1">
							<%

	while not consulta.EOF

	n = consulta("id_imovel")
%>
							<tr>
							  <td width="20%" height="20" bgcolor="#F7F7F7" class="style36"><div align="center" class="style40"><a href="ve_imovel.asp?id_imovel=<%=consulta("id_imovel")%>" style="text-decoration:none; color:#666666">
								<% =consulta("referencia") %>
								</a> </div></td>
									<td width="22%" bgcolor="#F7F7F7" class="style36"><div align="center" class="style40"><a href="ve_imovel.asp?id_imovel=<%=consulta("id_imovel")%>" style="text-decoration:none; color:#666666">
									  <% =consulta("bairro") %>
									  </a></div></td>
									<td width="16%" bgcolor="#F7F7F7" class="style36"><div align="center" class="style40">
									  <% =consulta("dormitorios") %>
									  </div></td>
									<td width="17%" bgcolor="#F7F7F7" class="style36"><div align="center" class="style40">
									  <% =consulta("vagas") %>
									  </div></td>
									<td bgcolor="#F7F7F7" class="style36"><div align="right" class="style40">
									  <div align="center">R$
										<% =consulta("valor") %>
										</div>
									</div>
										<div align="center"></div></td>
								  </tr>
							<%

	consulta.MoveNext
	WEnd

%>
							</table>
							  <%
	end if
	'fechaconexao
	conexao.close
	Set conexao = Nothing
	end if 
%>
						  <%

If Trim( Request.Form("tp_imovel") ) ="0" AND Trim( Request.Form("desc_aluguel") ) <> "" AND Trim( Request.Form("referencia")) <> "" Then

		comandosql = "SELECT * FROM imovel WHERE (((desc_aluguel) Like '*')) AND ((referencia) Like '*') AND ativo = '1' ORDER BY nivel_prioridade ASC"

		comandosql = "SELECT * FROM imovel "

		comandosql = comandosql & " Where desc_aluguel Like '%" & Request("desc_aluguel") & "%' AND referencia Like '%" & Request("referencia") & "%' AND ativo = '1' ORDER BY nivel_prioridade ASC"


		Set conexao =  Server.CreateObject("ADODB.Connection")
		conexao.Open "DBQ=" & Server.MapPath("..\bd\bd.mdb") & ";Driver={Microsoft Access Driver (*.mdb)}"
		Set consulta = conexao.Execute(comandosql)

			total = 0
		while not consulta.EOF
			total = total + 1
			consulta.MoveNext
		wend

		if total > 0 then
		consulta.MoveFirst


%>
						  <table border="0" width="100%" cellspacing="1">
							<%

	while not consulta.EOF

	n = consulta("id_imovel")
%>
							<tr>
							  <td width="20%" height="20" bgcolor="#F7F7F7" class="style36"><div align="center" class="style40"><a href="ve_imovel.asp?id_imovel=<%=consulta("id_imovel")%>" style="text-decoration:none; color:#666666">
								<% =consulta("referencia") %>
								</a> </div></td>
									<td width="22%" bgcolor="#F7F7F7" class="style36"><div align="center" class="style40"><a href="ve_imovel.asp?id_imovel=<%=consulta("id_imovel")%>" style="text-decoration:none; color:#666666">
									  <% =consulta("bairro") %>
									  </a></div></td>
									<td width="16%" bgcolor="#F7F7F7" class="style36"><div align="center" class="style40">
									  <% =consulta("dormitorios") %>
									  </div></td>
									<td width="17%" bgcolor="#F7F7F7" class="style36"><div align="center" class="style40">
									  <% =consulta("vagas") %>
									  </div></td>
									<td bgcolor="#F7F7F7" class="style36"><div align="right" class="style40">
									  <div align="center">R$
										<% =consulta("valor") %>
										<div align="center"></div>
										</div>
									</div></td>
								  </tr>
							<%

	consulta.MoveNext
	WEnd

%>
							</table>
							  <%
	end if
	'fechaconexao
	conexao.close
	Set conexao = Nothing
	end if 
%>
							  <%

If Trim( Request.Form("tp_imovel") ) = "0" AND Trim( Request.Form("desc_aluguel")) ="0" AND Trim( Request.Form("referencia")) > "0" Then

		comandosql = "SELECT tp_imovel FROM imovel WHERE (((referencia) Like '*'))AND ativo = '1' ORDER BY nivel_prioridade ASC"

		comandosql = "SELECT * FROM imovel "

		comandosql = comandosql & " Where referencia Like '%" & Request("referencia") & "%'AND ativo = '1' ORDER BY nivel_prioridade ASC"


		Set conexao =  Server.CreateObject("ADODB.Connection")
		conexao.Open "DBQ=" & Server.MapPath("..\bd\bd.mdb") & ";Driver={Microsoft Access Driver (*.mdb)}"
		Set consulta = conexao.Execute(comandosql)

			total = 0
		while not consulta.EOF
			total = total + 1
			consulta.MoveNext
		wend

		if total > 0 then
		consulta.MoveFirst


%>
							  <table border="0" width="100%" cellspacing="1">
								<%

	while not consulta.EOF

	n = consulta("id_imovel")
%>
								<tr>
								  <td width="20%" height="20" bgcolor="#F7F7F7" class="style36"><div align="center" class="style40"><a href="ve_imovel.asp?id_imovel=<%=consulta("id_imovel")%>" style="text-decoration:none; color:#666666">
									  <% =consulta("referencia") %>
								  </a> </div></td>
								  <td width="22%" bgcolor="#F7F7F7" class="style36"><div align="center" class="style40"><a href="ve_imovel.asp?id_imovel=<%=consulta("id_imovel")%>" style="text-decoration:none; color:#666666">
									  <% =consulta("bairro") %>
								  </a></div></td>
								  <td width="16%" bgcolor="#F7F7F7" class="style36"><div align="center" class="style40">
									  <% =consulta("dormitorios") %>
								  </div></td>
								  <td width="17%" bgcolor="#F7F7F7" class="style36"><div align="center" class="style40">
									  <% =consulta("vagas") %>
								  </div></td>
								  <td bgcolor="#F7F7F7" class="style36"><div align="right" class="style40">
									  <div align="center">R$
										<% =consulta("valor") %>
										  <div align="center"></div>
									  </div>
								  </div></td>
								</tr>
								<%

	consulta.MoveNext
	WEnd

%>
							  </table>
							  <%
	end if
	'fechaconexao
	conexao.close
	Set conexao = Nothing
	end if 
%>
							  <%
'##########################################################
' ESSE É O CAMPO QUE FILTRARIA O CAMPO VALOR MINIMO
'##########################################################

If Trim( Request.Form("tp_imovel") ) = "0" AND Trim( Request.Form("desc_aluguel")) ="0" AND Trim( Request.Form("referencia")) > "0" AND  Trim(request.form("valor_minimo"))<> "0" Then

		comandosql = "SELECT * FROM imovel WHERE valor >= '"& valor_minimo &"' AND ativo = '1' ORDER BY nivel_prioridade ASC"

		Set conexao =  Server.CreateObject("ADODB.Connection")
		conexao.Open "DBQ=" & Server.MapPath("..\bd\bd.mdb") & ";Driver={Microsoft Access Driver (*.mdb)}"
		Set consulta = conexao.Execute(comandosql)

			total = 0
		while not consulta.EOF
			total = total + 1
			consulta.MoveNext
		wend

		if total > 0 then
		consulta.MoveFirst


%>
							  <table border="0" width="100%" cellspacing="1">
								<%

	while not consulta.EOF

	n = consulta("id_imovel")
%>
								<tr>
								  <td width="20%" height="20" bgcolor="#F7F7F7" class="style36"><div align="center" class="style40"><a href="ve_imovel.asp?id_imovel=<%=consulta("id_imovel")%>" style="text-decoration:none; color:#666666">
									  <% =consulta("referencia") %>
								  </a> </div></td>
								  <td width="22%" bgcolor="#F7F7F7" class="style36"><div align="center" class="style40"><a href="ve_imovel.asp?id_imovel=<%=consulta("id_imovel")%>" style="text-decoration:none; color:#666666">
									  <% =consulta("bairro") %>
								  </a></div></td>
								  <td width="16%" bgcolor="#F7F7F7" class="style36"><div align="center" class="style40">
									  <% =consulta("dormitorios") %>
								  </div></td>
								  <td width="17%" bgcolor="#F7F7F7" class="style36"><div align="center" class="style40">
									  <% =consulta("vagas") %>
								  </div></td>
								  <td bgcolor="#F7F7F7" class="style36"><div align="right" class="style40">
									  <div align="center">R$
										<% =consulta("valor") %>
										  <div align="center"></div>
									  </div>
								  </div></td>
								</tr>
								<%

	consulta.MoveNext
	WEnd

%>
							  </table>
							  <%
	end if
	'fechaconexao
	conexao.close
	Set conexao = Nothing
	end if 
%>
							  <%
'#############################################################
' ESTE CAMPO AINDA NÃO FOI PROGRAMADO ELE SERIA O QUE FILTRARIA O VALO MAXIMO
'#############################################################

If Trim( Request.Form("tp_imovel") ) = "0" AND Trim( Request.Form("desc_aluguel")) = "0" AND Trim ( Request.Form("referencia")) = "0" Then
%>
		
						  <table border="0" width="100%" cellspacing="1">
		
							<tr>
							  <td height="20" bgcolor="#F7F7F7" class="style36"><div align="center" class="style40"><br>
								  <strong> Não foi informado nenhum dado. </strong></div>								
							  <div align="center" class="style40"></div>								<div align="center" class="style40"></div>								<div align="center" class="style40"></div>
								<div align="right" class="style40">
								  <div align="center"></div>
									</div>								<div align="center"></div></td>
								  </tr>
						   </table>
<%
	end if
%>
							  </td></tr>
				  </table></td>
				</tr>
			</table></td>
			  </tr>
			  <tr>
				<td height="10" valign="top" bgcolor="#FFFFFF"><table width="700" border="0" cellspacing="0" cellpadding="0" align="center">
				  <tr>
					<td bgcolor="#0059B3"><table width="90%" border="0" cellspacing="0" cellpadding="7" align="center">
					  <tr>
						<td class="textobr"><div align="center"><font color="#FFFFFF">Moradia Imobiliária 
						  - Tel.: (11) 6546.2299 – Fax: (11) 6943.2121 - contato@moradia.imb.br</font></div></td>
					  </tr>
					</table></td>
				  </tr>
				</table></td>
			  </tr>
			</table></td>
		</tr>
	  </table></td>
	</tr>
  </table>
</FORM>
</BODY>

Compartilhar este post


Link para o post
Compartilhar em outros sites

Cara.;.. nao tive paciencia para ler seu código todo... mas se você qr fazer uma busca por valor minimo... o correto é assim:

 

SQL = SELECT & FROM Tabela WHERE Campo >= '" & Variavel com o valor & "'"

Assim, ele fará a busca varrendo o BD atras de calores MAIORES ou IGUAIS ao valor passado pela variavel...

 

Abraços...

Compartilhar este post


Link para o post
Compartilhar em outros sites

Ainda não deu certo ...

 

o codigo que faz o filtro é esse ...

 

<%

If Trim( Request.Form("tp_imovel") ) = "0" AND Trim( Request.Form("desc_aluguel")) ="0" AND Trim( Request.Form("referencia")) = "0" AND Trim( Request.Form("valor_minimo")) <>"0" Then
	
		comandosql = "SELECT * FROM imovel WHERE valor >= '" & valor_minimo & "'"


		Set conexao =  Server.CreateObject("ADODB.Connection")
		conexao.Open "DBQ=" & Server.MapPath("..\bd\bd.mdb") & ";Driver={Microsoft Access Driver (*.mdb)}"
		Set consulta = conexao.Execute(comandosql)

			total = 0
		while not consulta.EOF
			total = total + 1
			consulta.MoveNext
		wend

		if total > 0 then
		consulta.MoveFirst


%>
							  <table border="0" width="100%" cellspacing="1">
								<%

	while not consulta.EOF

	n = consulta("id_imovel")
%>
								<tr>
								  <td width="20%" height="20" bgcolor="#F7F7F7" class="style36"><div align="center" class="style40"><a href="ve_imovel.asp?id_imovel=<%=consulta("id_imovel")%>" style="text-decoration:none; color:#666666">
									  <% =consulta("referencia") %>
								  </a> </div></td>
								  <td width="22%" bgcolor="#F7F7F7" class="style36"><div align="center" class="style40"><a href="ve_imovel.asp?id_imovel=<%=consulta("id_imovel")%>" style="text-decoration:none; color:#666666">
									  <% =consulta("bairro") %>
								  </a></div></td>
								  <td width="16%" bgcolor="#F7F7F7" class="style36"><div align="center" class="style40">
									  <% =consulta("dormitorios") %>
								  </div></td>
								  <td width="17%" bgcolor="#F7F7F7" class="style36"><div align="center" class="style40">
									  <% =consulta("vagas") %>
								  </div></td>
								  <td bgcolor="#F7F7F7" class="style36"><div align="right" class="style40">
									  <div align="center">R$
										<% =consulta("valor") %>
										  <div align="center"></div>
									  </div>
								  </div></td>
								</tr>
								<%

	consulta.MoveNext
	WEnd

%>
							  </table>
							  <%
	end if
	'fechaconexao
	conexao.close
	Set conexao = Nothing
	end if 
%>

o que estou fazendo de errado... ????

Compartilhar este post


Link para o post
Compartilhar em outros sites

esta dando algum erro ou apenas nao tem o resultado desejado?

Compartilhar este post


Link para o post
Compartilhar em outros sites

esta dando algum erro ou apenas nao tem o resultado desejado?

 

Não está aparecendo nenhum erro, simplismente não traz resultado correto.

Compartilhar este post


Link para o post
Compartilhar em outros sites

a coluna valor é de que tipo de dados?

Eu coloquei no banco ( mdb ) com texto porem aparece da seguinte forma o conteudo 5000 = 50.00

 

entendeu ...

Compartilhar este post


Link para o post
Compartilhar em outros sites

utilize a formatação money(moeda) e faça a consulta de acordo com essa logica

 

sql = "select campo from tabela where valor >="&replace(replace(valor,".",""),",",".")&""

Compartilhar este post


Link para o post
Compartilhar em outros sites

O sistema me aparece erro

 

Tipo de erro:

Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)

[Microsoft][Driver ODBC para Microsoft Access] Erro de sintaxe (operador faltando) na expressão de consulta 'valor campo'.

buscar.asp, line 197

 

<%

 

If Trim( Request.Form("tp_imovel") ) = "0" AND Trim( Request.Form("desc_aluguel")) ="0" AND Trim( Request.Form("referencia")) = "0" AND Trim( Request.Form("valor_minimo")) <>"0" Then

 

 

comandosql = "select valor campo from imovel where valor >="&replace(replace(valor,".",""),",",".")&""

 

 

'comandosql = "SELECT * FROM imovel WHERE valor >= '" & valor_minimo & "'"

 

 

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

conexao.Open "DBQ=" & Server.MapPath("..\bd\bd.mdb") & ";Driver={Microsoft Access Driver (*.mdb)}"

Set consulta = conexao.Execute(comandosql)' ESTA É A LINHA 197

 

total = 0

while not consulta.EOF

total = total + 1

consulta.MoveNext

wend

 

if total > 0 then

consulta.MoveFirst

 

 

%>

<table border="0" width="100%" cellspacing="1">

<%

 

while not consulta.EOF

 

n = consulta("id_imovel")

%>

<tr>

<td width="20%" height="20" bgcolor="#F7F7F7" class="style36"><div align="center" class="style40"><a href="ve_imovel.asp?id_imovel=<%=consulta("id_imovel")%>" style="text-decoration:none; color:#666666">

<% =consulta("referencia") %>

</a> </div></td>

<td width="22%" bgcolor="#F7F7F7" class="style36"><div align="center" class="style40"><a href="ve_imovel.asp?id_imovel=<%=consulta("id_imovel")%>" style="text-decoration:none; color:#666666">

<% =consulta("bairro") %>

</a></div></td>

<td width="16%" bgcolor="#F7F7F7" class="style36"><div align="center" class="style40">

<% =consulta("dormitorios") %>

</div></td>

<td width="17%" bgcolor="#F7F7F7" class="style36"><div align="center" class="style40">

<% =consulta("vagas") %>

</div></td>

<td bgcolor="#F7F7F7" class="style36"><div align="right" class="style40">

<div align="center">R$

<% =consulta("valor") %>

<div align="center"></div>

</div>

</div></td>

</tr>

<%

 

consulta.MoveNext

WEnd

 

%>

</table>

<%

end if

'fechaconexao

conexao.close

Set conexao = Nothing

end if

%>

O que estou fazendo de errado ?

 

Valew

Compartilhar este post


Link para o post
Compartilhar em outros sites

comandosql = "select valor campo from imovel where valor >="&replace(replace(valor,".",""),",",".")&""

 

O problema está nesta parte: select valor campo

 

Se o campo a ser selecionado se chama "valor campo" ( com espaço entre as palavras ), você deve coloca-lo entre colchetes: [valor campo].

 

Se você qr selecionar 2 campos diferentes, deve separa-los por virgula: valor,campo.

 

Então corriga isso..

 

Abraços...

Compartilhar este post


Link para o post
Compartilhar em outros sites

Estranho continua dando erro

 

O BD está como Moeda o campo valor

 

o Combo está da seguinte forma.

 

<select size="1" name="valor_minimo" class="cx">

<option value="0">Valor Mínimo</option>

<option value="0">R$ 0</option>

<option value="500,00">R$ 500,00</option>

<option value="1.000,00">R$ 1000,00</option>

<option value="1.500,00">R$ 150,00</option>

<option value="2.000,00">R$ 2000,00</option>

<option value="2.500,00">R$ 2500,00</option>

<option value="3.000,00">R$ 3000,00</option>

<option value="3.500,00">R$ 3500,00</option>

<option value="4.000,00">R$ 4000,00</option>

<option value="4.500,00">R$ 4500,00</option>

</select>

 

<%

 

If Trim( Request.Form("tp_imovel")) ="0" AND Trim( Request.Form("desc_aluguel")) ="0" AND Trim( Request.Form ("referencia"))<> "0" and trim(request.form("valor_minimo")) <>"" Then

 

comandosql = "select valor from imovel where valor >='"&replace(replace(valor_minimo,".",""),",",".")&"'"

 

'############################################################################

#######################

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

conexao.Open "DBQ=" & Server.MapPath("..\bd\bd.mdb") & ";Driver={Microsoft Access Driver (*.mdb)}"

Set consulta = conexao.Execute(comandosql)

'############################################################################

#######################

 

total = 0

while not consulta.EOF

total = total + 1

consulta.MoveNext

wend

 

if total > 0 then

consulta.MoveFirst

 

 

%>

<table border="0" width="100%" cellspacing="1">

<%

 

while not consulta.EOF

 

n = consulta("id_imovel")

%>

<tr>

<td width="20%" height="20" bgcolor="#F7F7F7" class="style39"><div align="center" class="style36"><a href="ve_imovel.asp?id_imovel=<%=consulta("id_imovel")%>" style="text-decoration:none; color:#666666">

<% =consulta("referencia") %>

</a> </div></td>

<td width="22%" bgcolor="#F7F7F7" class="style39"><div align="center" class="style36"><a href="ve_imovel.asp?id_imovel=<%=consulta("id_imovel")%>" style="text-decoration:none; color:#666666">

<% =consulta("bairro") %>

</a></div></td>

<td width="16%" bgcolor="#F7F7F7" class="style39"><div align="center" class="style36">

<% =consulta("dormitorios") %>

</div></td>

<td width="17%" bgcolor="#F7F7F7" class="style39"><div align="center" class="style36">

<% =consulta("vagas") %>

</div></td>

<td bgcolor="#F7F7F7" class="style39"><div align="right" class="style36">

<div align="center">R$

<% =consulta("valor") %>

</div>

</div></td>

</tr>

<%

 

consulta.MoveNext

WEnd

 

%>

</table>

<%

end if

'fechaconexao

conexao.close

Set conexao = Nothing

end if

%>

 

A onde está o erro ????

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.