Usuário com melhor resposta
Duvida ,

Pergunta
-
Olá estou com o problema no meu cod e não estou conseguindo revolver alguem pode me ajudar.
Então este cod e de uma tela de busca avançada .
porém quando eu seleciono o que tem no combobox e click em busca ele da este erro.
ai vai meu codigo.
olha o erro :
Microsoft OLE DB Provider for SQL Server error '80040e14'
Incorrect syntax near '='.
/Chamado/consu_empresa.old.asp, line 241
<form id="consulta" name="consulta" method="post" action="consu_empresa.old.asp">
<br />
<!--#include file="conexao.asp"-->
<%
Dim Pesquisa : Pesquisa = Request.Form("Pesquisa")
Dim Ordem : Ordem = Request.Form("radio_ordem")
Dim Pesqui : Pesqui = Request.Form("radio_pesquisa")
Dim acao : acao = Request.Form("acao")
Dim buscar_por : buscar_por = Request.Form("txt_Busca")
Dim RS_BUSCA
' EXEMPLO
' tipopesquisa = "nome"
' tipoordem = "decrescente"
' tipobusca = "aleatorio"
' valordapesquisa = "Joao"
%>
<%
' COMEÇO DO TESTE ...
' FIM TESTE PARA SELECT "
%>
<table width="" border="0"" cellpadding="2" cellspacing="2">
<tr>
<td width="189" class="style7"> Campo de Pesquisa: <br/>
<select name="Pesquisa" class="campo" id="Pesquisa">
<option><-- Selecione --></option>
<option value="Codigo">Codigo</option>
<option value="Nome Fantasia">Nome Fantasia</option>
<option value="Razão Social">Razão Social</option>
</select> </td>
<td width="223" class="style7"> Ordem: <br />
<fieldset class="style8">
<input name="radio_ordem" type="radio" value="Crescente" />
Crescente
<input name="radio_ordem" type="radio" value="Descrescente"/>
Decrescente
</fieldset></td>
</tr>
<tr>
<td class="style7">Pesquisa: <br />
<fieldset class="">
<input name="radio_pesqusa" type="radio" value="Inicio" />
Inicio da Frase
<input name="radio_pesqusa" type="radio" value="Aleatorio" />
Aleatório
</fieldset></td>
</tr>
<tr>
<td class="style7">Busca:<br />
<input name="txt_Busca" type="text" class="campo" id="txt_Busca" size="30" maxlength="50" /></td>
</tr>
</table>
<table width="" border="0" cellpadding="2" cellspacing="2">
<%
IF acao = "buscar" THEN
SQL = "SELECT ID_EMPRESA, RAZAO_SOCIAL, NOME_FANTASIA, CEP, ENDERECO, NUMERO, COMPLEMENTO, BAIRRO, CIDADE, ESTADO, EMAIL, TELEFONE FROM EMPRESA"IF Pesquisa = "NOME_FANTASIA" THEN
SQL = SQL & " WHERE NOME_FANTASIA "
ELSE
SQL = SQL & " WHERE ID_EMPRESA "
END IF
IF nome <> "" THEN
IF Pesqui = "Inicio" THEN
SQL = SQL & " LIKE %'"&buscar_por&"'"
ELSE
SQL = SQL & " LIKE %'"&buscar_por&"'%"
END IF
ELSE
SQL = SQL & " = " & buscar_por
END IF
IF Ordem = "Decrescente" THEN
SQL = SQL & " ORDER BY DESC"
END IF
SET RS_BUSCA = conexao.execute(SQL)' SET RS_BUSCA RECOR SET = MINHA CONEXÃO EXECUTE O MEU COMANDO SQL.
'RS_BUSCA.open SQL,conexao
if RS_BUSCA.bof or RS_BUSCA.eof then %>
<tr class="style7">
<td width=""><div align="center" class="style8">
<div align="center" class="campo"><strong>SUA BUSCA NÃO RETORNOU RESULTADO!!</strong></div>
</div></td>
</tr>
<%else
End if%>
</table>
<table width="" border="0" bgcolor="">
<tr class="style8">
<td width="" class="style7"><strong><span class="style3 style6 style8">Codigo Empresa </span></strong></td>
<td width="" class="style7"><strong><span class="style3 style6 style8">Razão Social </span></strong></td>
<td width="" class="style7"><strong><span class="style9">Nome Fantasia</span></strong></td>
<td width="" class="style7"><strong><span class="style3 style6 style8">Cep</span></strong></td>
<td width="" class="style7"><strong><span class="style3 style6 style8">Endereço</span></strong></td>
<td width="" class="style7"><strong><span class="style3 style6 style8">Numero</span></strong></td>
<td width="" class="style7"><strong><span class="style3 style6 style8">Complemento</span></strong></td>
<td width="" class="style7"><strong><span class="style3 style6 style8">Bairro</span></strong></td>
<td width="" class="style7"><strong><span class="style3 style6 style8">Cidade</span></strong></td>
<td width="" class="style7"><strong><span class="style3 style6 style8">Estado </span></strong></td>
<td width="" class="style7"><strong class="style8">E_mail</strong></td>
<td width="" class="style7"><strong class="style8">Telefone</strong></td>
</tr>
<tr class="style7">
<%
Do While RS_BUSCA.Eof=false
%>
<td height="" bgcolor="#FFFFFF" class="style7"><strong><span class="style8"><%=RS_BUSCA("ID_EMPRESA")%></span></strong></td>
<td bgcolor="#FFFFFF" class="style7"><strong><span class="style8"><%=RS_BUSCA("RAZAO_SOCIAL")%></span></strong></td>
<td bgcolor="#FFFFFF" class="style7"><strong><span class="style8"><%=RS_BUSCA("NOME_FANTASIA")%></span></strong></td>
<td bgcolor="#FFFFFF" class="style7"><strong><span class="style8"><%=RS_BUSCA("CEP")%></span></strong></td>
<td bgcolor="#FFFFFF" class="style7"><strong><span class="style8"><%=RS_BUSCA("ENDERECO")%></span></strong></td>
<td bgcolor="#FFFFFF" class="style7"><strong><span class="style8"><%=RS_BUSCA("NUMERO")%></span></strong></td>
<td bgcolor="#FFFFFF" class="style7"><strong><span class="style8"><%=RS_BUSCA("COMPLEMENTO")%></span></strong></td>
<td bgcolor="#FFFFFF" class="style7"><strong><span class="style8"><%=RS_BUSCA("BAIRRO")%></span></strong></td>
<td bgcolor="#FFFFFF" class="style7"><strong><span class="style8"><%=RS_BUSCA("CIDADE")%></span></strong></td>
<td bgcolor="#FFFFFF" class="style7"><strong><span class="style8"><%=RS_BUSCA("ESTADO")%></span></strong></td>
<td bgcolor="#FFFFFF" class="style7"><strong><span class="style8"><%=RS_BUSCA("EMAIL")%></span></strong></td>
<td bgcolor="#FFFFFF" class="style7"><strong><span class="style8"><%=RS_BUSCA("TELEFONE")%></span></strong></td>
</tr>
<%
RS_BUSCA.MoveNext
Loop
End If
%>
<tr>
<td height="" colspan="13" bgcolor="#FFFFFF">
<div align="center">
<input name="bt_pesquisar" type="submit" class="botao" id="bt_pesquisar" value="Buscar"/>
<input name="bt_voltar" type="reset" class="botao" id="bt_voltar" value="Limpar"/>
<input name="acao" type="hidden" id="acao" value="buscar"/>
</div></td>
</tr>
</table>
</form>
</table></td>
</tr>
<tr>
<td height="15" colspan="3" bgcolor="#265490"></td>
</tr>
</table>
</table>
</body>
</html>
Respostas
-
o que acontece quando eu seleciono uma empresa tipo Razão_social e também seleicono ordem decrescente ..
E click no buscar ele não traz nada !
Tem outro erro também quando eu seleciono Razão Social e seleciono também pesquisa inicio de frase ..e digite um a letra D no campo ..ele mostra um erro.
Olha o erro :Microsoft OLE DB Provider for SQL Server error '80040e07'
Conversion failed when converting the varchar value 'd' to data type int.
/Chamado/consu_empresa.old.asp, line 244
Olha o codigo :
<%
IF acao = "buscar" THEN
SQL = "SELECT ID_EMPRESA, RAZAO_SOCIAL, NOME_FANTASIA, CEP, ENDERECO, NUMERO, COMPLEMENTO, BAIRRO, CIDADE, ESTADO, EMAIL, TELEFONE FROM EMPRESA"
IF Pesquisa = "NOME_FANTASIA" THEN
SQL = SQL & " WHERE NOME_FANTASIA "
ELSE
SQL = SQL & " WHERE ID_EMPRESA "
END IF
IF nome <> "" THEN
IF Pesqui = "Inicio" THEN
SQL = SQL & " LIKE %'"&buscar_por&"'"
ELSE
SQL = SQL & " LIKE %'"&buscar_por&"'%"
END IF
ELSE
SQL = SQL & " = '" & buscar_por & "'"
END IF
IF Ordem = "Decrescente" THEN
SQL = SQL & " ORDER BY DESC"
END IF
SET RS_BUSCA = conexao.execute(SQL)' SET RS_BUSCA RECOR SET = MINHA CONEXÃO EXECUTE O MEU COMANDO SQL.
'RS_BUSCA.open SQL,conexao
if RS_BUSCA.bof or RS_BUSCA.eof then %>
<tr class="style7">
<td width=""><div align="center" class="style8">
<div align="center" class="campo"><strong>SUA BUSCA NÃO RETORNOU RESULTADO!!</strong></div>
</div></td>
</tr>
<%else
End if%>
</table>
<table width="" border="0" bgcolor="">
<tr class="style8">
<td width="" class="style7"><strong><span class="style3 style6 style8">Codigo Empresa </span></strong></td>
<td width="" class="style7"><strong><span class="style3 style6 style8">Razão Social </span></strong></td>
<td width="" class="style7"><strong><span class="style9">Nome Fantasia</span></strong></td>
<td width="" class="style7"><strong><span class="style3 style6 style8">Cep</span></strong></td>
<td width="" class="style7"><strong><span class="style3 style6 style8">Endereço</span></strong></td>
<td width="" class="style7"><strong><span class="style3 style6 style8">Numero</span></strong></td>
<td width="" class="style7"><strong><span class="style3 style6 style8">Complemento</span></strong></td>
<td width="" class="style7"><strong><span class="style3 style6 style8">Bairro</span></strong></td>
<td width="" class="style7"><strong><span class="style3 style6 style8">Cidade</span></strong></td>
<td width="" class="style7"><strong><span class="style3 style6 style8">Estado </span></strong></td>
<td width="" class="style7"><strong class="style8">E_mail</strong></td>
<td width="" class="style7"><strong class="style8">Telefone</strong></td>
</tr>
<tr class="style7">
<%
Do While RS_BUSCA.Eof=false
%>
<td height="" bgcolor="#FFFFFF" class="style7"><strong><span class="style8"><%=RS_BUSCA("ID_EMPRESA")%></span></strong></td>
<td bgcolor="#FFFFFF" class="style7"><strong><span class="style8"><%=RS_BUSCA("RAZAO_SOCIAL")%></span></strong></td>
<td bgcolor="#FFFFFF" class="style7"><strong><span class="style8"><%=RS_BUSCA("NOME_FANTASIA")%></span></strong></td>
<td bgcolor="#FFFFFF" class="style7"><strong><span class="style8"><%=RS_BUSCA("CEP")%></span></strong></td>
<td bgcolor="#FFFFFF" class="style7"><strong><span class="style8"><%=RS_BUSCA("ENDERECO")%></span></strong></td>
<td bgcolor="#FFFFFF" class="style7"><strong><span class="style8"><%=RS_BUSCA("NUMERO")%></span></strong></td>
<td bgcolor="#FFFFFF" class="style7"><strong><span class="style8"><%=RS_BUSCA("COMPLEMENTO")%></span></strong></td>
<td bgcolor="#FFFFFF" class="style7"><strong><span class="style8"><%=RS_BUSCA("BAIRRO")%></span></strong></td>
<td bgcolor="#FFFFFF" class="style7"><strong><span class="style8"><%=RS_BUSCA("CIDADE")%></span></strong></td>
<td bgcolor="#FFFFFF" class="style7"><strong><span class="style8"><%=RS_BUSCA("ESTADO")%></span></strong></td>
<td bgcolor="#FFFFFF" class="style7"><strong><span class="style8"><%=RS_BUSCA("EMAIL")%></span></strong></td>
<td bgcolor="#FFFFFF" class="style7"><strong><span class="style8"><%=RS_BUSCA("TELEFONE")%></span></strong></td>
</tr>
<%
RS_BUSCA.MoveNext
Loop
End If
%>
<tr>
<td height="" colspan="13" bgcolor="#FFFFFF">
<div align="center">
<input name="bt_pesquisar" type="submit" class="botao" id="bt_pesquisar" value="Buscar"/>
<input name="bt_voltar" type="reset" class="botao" id="bt_voltar" value="Limpar"/>
<input name="acao" type="hidden" id="acao" value="buscar"/>
</div></td>
</tr>
</table>
</form>
</table></td>
</tr>
<tr>
<td height="15" colspan="3" bgcolor="#265490"></td>
</tr>
</table>
</table>
Todas as Respostas
-
Olá Emerson. Tudo bom?
Posso estar enganado, não sei exatamente como esta modelado o seu banco, mas pelo q eu entendi do erro, o problema esta aqui:
IF Pesqui = "Inicio" THEN
SQL = SQL & " LIKE %'"&buscar_por&"'"
ELSE
SQL = SQL & " LIKE %'"&buscar_por&"'%"
END IF
ELSE
SQL = SQL & " = " & buscar_por
END IFpoque não tenta concatenar aspas simples apos o igual?
Code BlockSQL = SQL & " = '" & buscar_por & "'"
Se não funcionar tenta explicar como esta modelado este campo no banco pq o problema parece estar ai.
Abraços!
-
o que acontece quando eu seleciono uma empresa tipo Razão_social e também seleicono ordem decrescente ..
E click no buscar ele não traz nada !
Tem outro erro também quando eu seleciono Razão Social e seleciono também pesquisa inicio de frase ..e digite um a letra D no campo ..ele mostra um erro.
Olha o erro :Microsoft OLE DB Provider for SQL Server error '80040e07'
Conversion failed when converting the varchar value 'd' to data type int.
/Chamado/consu_empresa.old.asp, line 244
Olha o codigo :
<%
IF acao = "buscar" THEN
SQL = "SELECT ID_EMPRESA, RAZAO_SOCIAL, NOME_FANTASIA, CEP, ENDERECO, NUMERO, COMPLEMENTO, BAIRRO, CIDADE, ESTADO, EMAIL, TELEFONE FROM EMPRESA"
IF Pesquisa = "NOME_FANTASIA" THEN
SQL = SQL & " WHERE NOME_FANTASIA "
ELSE
SQL = SQL & " WHERE ID_EMPRESA "
END IF
IF nome <> "" THEN
IF Pesqui = "Inicio" THEN
SQL = SQL & " LIKE %'"&buscar_por&"'"
ELSE
SQL = SQL & " LIKE %'"&buscar_por&"'%"
END IF
ELSE
SQL = SQL & " = '" & buscar_por & "'"
END IF
IF Ordem = "Decrescente" THEN
SQL = SQL & " ORDER BY DESC"
END IF
SET RS_BUSCA = conexao.execute(SQL)' SET RS_BUSCA RECOR SET = MINHA CONEXÃO EXECUTE O MEU COMANDO SQL.
'RS_BUSCA.open SQL,conexao
if RS_BUSCA.bof or RS_BUSCA.eof then %>
<tr class="style7">
<td width=""><div align="center" class="style8">
<div align="center" class="campo"><strong>SUA BUSCA NÃO RETORNOU RESULTADO!!</strong></div>
</div></td>
</tr>
<%else
End if%>
</table>
<table width="" border="0" bgcolor="">
<tr class="style8">
<td width="" class="style7"><strong><span class="style3 style6 style8">Codigo Empresa </span></strong></td>
<td width="" class="style7"><strong><span class="style3 style6 style8">Razão Social </span></strong></td>
<td width="" class="style7"><strong><span class="style9">Nome Fantasia</span></strong></td>
<td width="" class="style7"><strong><span class="style3 style6 style8">Cep</span></strong></td>
<td width="" class="style7"><strong><span class="style3 style6 style8">Endereço</span></strong></td>
<td width="" class="style7"><strong><span class="style3 style6 style8">Numero</span></strong></td>
<td width="" class="style7"><strong><span class="style3 style6 style8">Complemento</span></strong></td>
<td width="" class="style7"><strong><span class="style3 style6 style8">Bairro</span></strong></td>
<td width="" class="style7"><strong><span class="style3 style6 style8">Cidade</span></strong></td>
<td width="" class="style7"><strong><span class="style3 style6 style8">Estado </span></strong></td>
<td width="" class="style7"><strong class="style8">E_mail</strong></td>
<td width="" class="style7"><strong class="style8">Telefone</strong></td>
</tr>
<tr class="style7">
<%
Do While RS_BUSCA.Eof=false
%>
<td height="" bgcolor="#FFFFFF" class="style7"><strong><span class="style8"><%=RS_BUSCA("ID_EMPRESA")%></span></strong></td>
<td bgcolor="#FFFFFF" class="style7"><strong><span class="style8"><%=RS_BUSCA("RAZAO_SOCIAL")%></span></strong></td>
<td bgcolor="#FFFFFF" class="style7"><strong><span class="style8"><%=RS_BUSCA("NOME_FANTASIA")%></span></strong></td>
<td bgcolor="#FFFFFF" class="style7"><strong><span class="style8"><%=RS_BUSCA("CEP")%></span></strong></td>
<td bgcolor="#FFFFFF" class="style7"><strong><span class="style8"><%=RS_BUSCA("ENDERECO")%></span></strong></td>
<td bgcolor="#FFFFFF" class="style7"><strong><span class="style8"><%=RS_BUSCA("NUMERO")%></span></strong></td>
<td bgcolor="#FFFFFF" class="style7"><strong><span class="style8"><%=RS_BUSCA("COMPLEMENTO")%></span></strong></td>
<td bgcolor="#FFFFFF" class="style7"><strong><span class="style8"><%=RS_BUSCA("BAIRRO")%></span></strong></td>
<td bgcolor="#FFFFFF" class="style7"><strong><span class="style8"><%=RS_BUSCA("CIDADE")%></span></strong></td>
<td bgcolor="#FFFFFF" class="style7"><strong><span class="style8"><%=RS_BUSCA("ESTADO")%></span></strong></td>
<td bgcolor="#FFFFFF" class="style7"><strong><span class="style8"><%=RS_BUSCA("EMAIL")%></span></strong></td>
<td bgcolor="#FFFFFF" class="style7"><strong><span class="style8"><%=RS_BUSCA("TELEFONE")%></span></strong></td>
</tr>
<%
RS_BUSCA.MoveNext
Loop
End If
%>
<tr>
<td height="" colspan="13" bgcolor="#FFFFFF">
<div align="center">
<input name="bt_pesquisar" type="submit" class="botao" id="bt_pesquisar" value="Buscar"/>
<input name="bt_voltar" type="reset" class="botao" id="bt_voltar" value="Limpar"/>
<input name="acao" type="hidden" id="acao" value="buscar"/>
</div></td>
</tr>
</table>
</form>
</table></td>
</tr>
<tr>
<td height="15" colspan="3" bgcolor="#265490"></td>
</tr>
</table>
</table> -
-
Valeu Peterson mais já revolvi o problema.
Grato pela atenção, ai vai o cod correto ..
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>:: Briefing _________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________</title>
<style type="text/css">body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
A.menu_sup {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
color: #ffffff;
}A.menu_sup:link {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
color: #ffffff;
}A.menu_sup:hover {
text-decoration: none;
color: #dadada;}
.campo {BACKGROUND: #f8f8f8;
COLOR: #265490;
BORDER-BOTTOM: #265490 1px solid;
BORDER-LEFT: #EFEFEF 1px solid;
BORDER-RIGHT: #265490 1px solid;
BORDER-TOP: #EFEFEF 1px solid;
FONT-SIZE: 10px;
height : 20;
}a {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
color: #265490;
}a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
}
a:hover {
text-decoration: none;
color: #999999;
}
a:active {
text-decoration: none;
}.style5 {color: #FFFFFF}
.style8 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
color: #255691;
}
.style7 {font-size: 10px; color: #1C406C; font-family: Verdana, Arial, Helvetica, sans-serif;}
.botao {BACKGROUND: #f8f8f8;
COLOR: #265490;
BORDER-BOTTOM: #265490 1px solid;
BORDER-LEFT: #EFEFEF 1px solid;
BORDER-RIGHT: #265490 1px solid;
BORDER-TOP: #EFEFEF 1px solid;
FONT-SIZE: 10px;
width:80px;
height : 20;
}
.style9 {color: #255691}
</style></head><body>
<table width="" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="502" height="100" background="images/topo_01.jpg"><img src="images/chamado_2_01.jpg" width="502" height="99" /></td>
<td width="100%" background="images/topo_01.jpg"> </td>
<td width="271"><img src="images/chamado_2_03.jpg" width="271" height="100" /></td>
</tr>
<tr>
<td height="1" colspan="3" bgcolor="#F8f8f8"></td>
</tr>
<tr>
<td colspan="3" valign="top" bgcolor="#FFFFFF"><table width="100%" border="0" align="right" cellpadding="0" cellspacing="0">
<tr>
<td width="1%" bgcolor="#265490"> </td>
<td width="100%" height="22" valign="top" bgcolor="#265490"><a href="cadastro.html" class="menu_sup"> Cadastro</a><span class="style5"> | </span><a href="processos.html" class="menu_sup">Processos</a> <span class="style5">| </span><a href="seguranca.html" class="menu_sup">Segurança</a> <span class="style5">|</span> <a href="relatorios.html" class="menu_sup">Relatórios</a> <span class="style5">|</span> <a href="gerenciamento.html" class="menu_sup">Gerenciamento</a> <span class="style5">|</span> <a href="logout.asp" class="menu_sup">Sair</a></td>
</tr>
</table></td>
</tr>
<tr>
<td height="1" colspan="3" bgcolor="#ffffff"></td>
</tr>
<tr>
<td height="" colspan="3"><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="20%" valign="top" bgcolor="#FFFFFF"><br />
<table width="95%" border="0" align="center" cellpadding="0" cellspacing="2">
<tr>
<td bgcolor="#FFFFFF"><img src="images/cadastro.jpg" width="136" height="28" /><br />
<img src="images/menuMiniBullet.gif" width="4" height="4" /> <a href="#">Empresas </a><br />
<img src="images/menuMiniBullet.gif" width="4" height="4" /> <a href="#">Funcionários</a><br />
<img src="images/menuMiniBullet.gif" width="4" height="4" /> <a href="#">Clientes</a><br />
<img src="images/menuMiniBullet.gif" width="4" height="4" /> <a href="#">Cargos</a><br />
<img src="images/menuMiniBullet.gif" width="4" height="4" /> <a href="#">Tipos de telefone </a></td>
</tr>
<tr>
<td> </td>
</tr>
</table></td>
<td width="" background="images/fd.jpg" bgcolor="#CCCCCC"> </td>
<td width="79%" valign="top" bgcolor="#FFFFFF">
<!-- <form action="consu_new.asp" method="post" name="consu_new" id="acao" onSubmit="return valida();" >-->
<script language="javascript">// FUNÇÃO PARA VALIDAR CAMPO.
function validar(){
consulta.txt_Busca.focus(document.consulta.txt_Busca.style.background ="");
consulta.Pesquisa.focus(document.consulta.Pesquisa.style.background ="");
if (consulta.Pesquisa.value ==""){
alert('POR FAVOR PREENCHA O CAMPO PESQUISA!');
consulta.Pesquisa.focus(document.consulta.Pesquisa.style.background ="#FFFFCC");
return false;
}
if (consulta.txt_Busca.value ==""){
alert('POR FAVOR PREENCHA O CAMPO BUSCA!');
consulta.txt_Busca.focus(document.consulta.txt_Busca.style.background ="#FFFFCC");
return false;
}
}
</script><script language="javascript">
// FUNÇÃO PARA VERIFICAR CAMPO.
function somenteinteiro(campo){
if (document.getElementById("Pesquisa").options[1].selected == true)
{
var tam = campo.value.length;
var charunicode;
for (var i = 0;i<tam;i++)
{
charunicode = campo.value.substring(i,i+1).charCodeAt();
if ((charunicode < 48) || (charunicode > 57))
{
window.alert("CARACTERE INVÁLIDO NO CAMPO BUSCA,VOCÊ ESCOLHEU A CONSULTA POR CÓDIGO!");
campo.value = campo.value.substring(i,i-1)
campo.focus;
break;
}
}
}
}</script>
<form id="consulta" name="consulta" method="post" action="consu_empresa.old.asp" onsubmit="return validar(this);">
<br />
<!--#include file="conexao.asp"-->
<%
Dim Pesquisa : Pesquisa = Request.Form("Pesquisa")
Dim Ordem : Ordem = Request.Form("radio_ordem")
Dim Pesqui : Pesqui = Request.Form("radio_pesquisa")
Dim acao : acao = Request.Form("acao")
Dim buscar_por
Dim RS_BUSCAIF Request.Form("txt_Busca")<>"" THEN
buscar_por = Request.Form("txt_Busca")
ELSE
buscar_por = Request.querystring("txt_Busca")
END IF
%>
<table width="" border="0"" cellpadding="2" cellspacing="2">
<tr>
<td width="189" class="style7"> Campo de Pesquisa:<br/>
<select name="Pesquisa" class="campo" id="Pesquisa">
<option><-- Selecione --></option>
<option value="ID_EMPRESA">Codigo</option>
<option value="NOME_FANTASIA">Nome Fantasia</option>
<option value="RAZAO_SOCIAL">Razão Social</option>
</select></td>
<td width="223" class="style7"> Ordem: <br />
<input name="radio_ordem" type="radio" value="Crescente" checked="checked" />
Crescente
<input name="radio_ordem" type="radio" value="Decrescente"/>
Decrescente </td>
</tr>
<td class="style7">Pesquisa:<br />
<input name="radio_pesquisa" type="radio" value="Inicio" checked="checked"/>
Inicio da Frase
<input name="radio_pesquisa" type="radio" value="Aleatorio"/>
Aleatório </td>
</tr>
<tr>
<td class="style7">Busca:<br />
<input name="txt_Busca" type="text" class="campo" id="txt_Busca" size="30" maxlength="50" onchange="somenteinteiro(this);"/>
</td>
</tr>
</table>
<table width="" border="0" cellpadding="2" cellspacing="2">
<%
IF acao = "buscar" THEN
SQL = "SELECT ID_EMPRESA, RAZAO_SOCIAL, NOME_FANTASIA, CEP, ENDERECO, NUMERO, COMPLEMENTO, BAIRRO, CIDADE, ESTADO, EMAIL, TELEFONE FROM EMPRESA"
IF Pesquisa = "NOME_FANTASIA" THEN
SQL = SQL & " WHERE NOME_FANTASIA "
ELSEIF Pesquisa = "RAZAO_SOCIAL" THEN
SQL = SQL & " WHERE RAZAO_SOCIAL "
ELSE
SQL = SQL & " WHERE ID_EMPRESA "
END IF
IF Pesquisa = "NOME_FANTASIA" OR Pesquisa = "RAZAO_SOCIAL" then
IF Pesqui = "Inicio" then
SQL = SQL & " LIKE '" & buscar_por & "%'"
ELSE
SQL = SQL & " LIKE '%" & buscar_por & "%'"
END IF
ELSE
SQL = SQL & " = " & buscar_por
END IF
IF Ordem = "Decrescente" THEN
IF Pesquisa = "NOME_FANTASIA" THEN
SQL = SQL & " ORDER BY NOME_FANTASIA DESC"
ELSEIF Pesquisa = "RAZAO_SOCIAL" THEN
SQL = SQL & " ORDER BY RAZAO_SOCIAL DESC"
ELSE
SQL = SQL & " ORDER BY ID_EMPRESA DESC"
END IF
ELSE
IF Pesquisa = "NOME_FANTASIA" THEN
SQL = SQL & " ORDER BY NOME_FANTASIA"
ELSEIF Pesquisa = "RAZAO_SOCIAL" THEN
SQL = SQL & " ORDER BY RAZAO_SOCIAL"
ELSE
SQL = SQL & ""
END IF
END IF
SET RS_BUSCA = conexao.execute(SQL)' SET RS_BUSCA RECOR SET = MINHA CONEXÃO EXECUTE O MEU COMANDO SQL.
'RS_BUSCA.open SQL,conexao
IF RS_BUSCA.bof or RS_BUSCA.eof THEN %>
<tr class="style7">
<td width=""><div align="center" class="style8">
<div align="center" class="campo"><strong>SUA BUSCA NÃO RETORNOU RESULTADO!!</strong></div>
</div></td>
</tr>
<%ELSE
END IF%>
</table>
<table border="0" bgcolor="">
<tr class="style8">
<td width="" class="style7"><strong><span class="style3 style6 style8">Codigo Empresa </span></strong></td>
<td width="" class="style7"><strong><span class="style3 style6 style8">Razão Social </span></strong></td>
<td width="" class="style7"><strong><span class="style9">Nome Fantasia</span></strong></td>
<td width="" class="style7"><strong><span class="style3 style6 style8">Cep</span></strong></td>
<td width="" class="style7"><strong><span class="style3 style6 style8">Endereço</span></strong></td>
<td width="" class="style7"><strong><span class="style3 style6 style8">Numero</span></strong></td>
<td width="" class="style7"><strong><span class="style3 style6 style8">Complemento</span></strong></td>
<td width="" class="style7"><strong><span class="style3 style6 style8">Bairro</span></strong></td>
<td width="" class="style7"><strong><span class="style3 style6 style8">Cidade</span></strong></td>
<td width="" class="style7"><strong><span class="style3 style6 style8">Estado </span></strong></td>
<td width="" class="style7"><strong class="style8">E_mail</strong></td>
<td width="" class="style7"><strong class="style8">Telefone</strong></td>
</tr>
<tr class="style7">
<%
DIM cor
Do While RS_BUSCA.Eof=false
if cor = "#eeeeee" then
cor = "#ffffff"
else
cor = "#eeeeee"
end if
%>
<td height="" bgcolor="<%=cor%>" class="style7"><a href="empresa.asp?ID_EMPRESA='<%=RS_BUSCA("ID_EMPRESA")%>'"><strong><span class="style8"><%=RS_BUSCA("ID_EMPRESA")%></span></strong></a></td>
<td bgcolor="<%=cor%>"class="style7"><strong><span class="style8"><%=RS_BUSCA("RAZAO_SOCIAL")%></span></strong></td>
<td bgcolor="<%=cor%>" class="style7"><strong><span class="style8"><%=RS_BUSCA("NOME_FANTASIA")%></span></strong></td>
<td bgcolor="<%=cor%>" class="style7"><strong><span class="style8"><%=RS_BUSCA("CEP")%></span></strong></td>
<td bgcolor="<%=cor%>" class="style7"><strong><span class="style8"><%=RS_BUSCA("ENDERECO")%></span></strong></td>
<td bgcolor="<%=cor%>" class="style7"><strong><span class="style8"><%=RS_BUSCA("NUMERO")%></span></strong></td>
<td bgcolor="<%=cor%>" class="style7"><strong><span class="style8"><%=RS_BUSCA("COMPLEMENTO")%></span></strong></td>
<td bgcolor="<%=cor%>" class="style7"><strong><span class="style8"><%=RS_BUSCA("BAIRRO")%></span></strong></td>
<td bgcolor="<%=cor%>" class="style7"><strong><span class="style8"><%=RS_BUSCA("CIDADE")%></span></strong></td>
<td bgcolor="<%=cor%>" class="style7"><strong><span class="style8"><%=RS_BUSCA("ESTADO")%></span></strong></td>
<td bgcolor="<%=cor%>" class="style7"><strong><span class="style8"><%=RS_BUSCA("EMAIL")%></span></strong></td>
<td bgcolor="<%=cor%>" class="style7"><strong><span class="style8"><%=RS_BUSCA("TELEFONE")%></span></strong></td>
</tr>
<%
RS_BUSCA.MoveNext
Loop
End If
%><tr>
<td height="" colspan="13" bgcolor="#FFFFFF">
<div align="center">
<input name="bt_pesquisar" type="submit" class="botao" id="bt_pesquisar" value="Buscar"/>
<input name="bt_voltar" type="reset" class="botao" id="bt_voltar" value="Limpar"/>
<input name="acao" type="hidden" id="acao" value="buscar"/>
</div>
</td>
</tr>
</table>
</form>
</table>
</td>
</tr>
<tr>
<td height="15" colspan="3" bgcolor="#265490"></td>
</tr>
</table>
</table>
</body>
</html>