Usuário com melhor resposta
Tela de Busca Completa !

Pergunta
-
Bom dia .
Galera estou fazendo uma tela de busca completa como funciona?
Esta tela de busca ela vai ter um campo List/Menu dentro deste List/Menu vou ter codigo, nome, etc
Em seguinta tenho um outro campo chamado ordem que tem 2 Radio Buton crescente e decrescente
Tenho também um outro campo chamado pesquisa que tem 2 Radio Buton inicio frase e aleatório.
E por ultimo um campo texto para digitar.Começei fazer porém tenho varias duvidas para desenvolver está tela alguem pode me ajudar por favor.
Olha meu codigo ..
<!--#include file="conexao.asp"-->
<!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;
}
</style></head><body>
<table width="100%" 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="430" 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="1" background="images/fd.jpg" bgcolor="#CCCCCC">
<p> </p></td>
<td width="79%" valign="top" bgcolor="#FFFFFF">
<form action="consu_new" method="post" name="consu_new;" id="consu_new" onSubmit="return valida();" >
<br />
<%Dim Campo_Pesquisa : Campo_Pesquisa = Request.Form("Pesquisa")
Dim Ordem : Ordem = Request.Form("radio_ordem")
Dim Pesquisa : Pesquisa = Request.Form("radio_pesquisa")
Dim Busca : Busca = Request.Form("txt_busca")
Dim acao : acao = Request.Form("acao")
%><%
If acao = "buscar" Then
Call conexao()
SQL = "SELECT ID_EMPRESA, ID_FUNCIONARIO, NOME, EMAIL, ID_CARGO, LOGIN, SENHA, HORA_INI, HORA_FIM, VALOR_HORA, FLG_TEMPORARIO FROM FUNCIONARIO WHERE NOME LIKE '%"& Busca &"%' "
Call AbreRS(oRS_Busca, SQL)
if oRS_Busca.bof or oRS_Busca.eof then%>
<%else
if request.Form("txt_Busca") = "" then%>
<%End if
End if
While Not oRS_Busca.Eof
%>
<%
oRS_Busca.MoveNext
Wend
End If%>
<table width="" border="0"" cellpadding="2" cellspacing="2">
<tr>
<td class="style7"> Campo de Pesquisa: <br/>
<select name="Pesquisa" class="campo" id="Pesquisa">
<option><-- Selecione --></option>
<option>Codigo</option>
<option>Nome</option>
</select> </td>
<td width="" class="style7"> Ordem: <br />
<fieldset class="">
<input name="radio_ordem" type="radio" value="radio_ordem" />
Crescente
<input name="radio_ordem" type="radio" value="radio_ordem" />
Decrescente
</fieldset></td>
</tr>
<tr>
<td class="style7">Pesquisa: <br />
<fieldset class="">
<input name="radio_pesqusa" type="radio" value="radio_pesqusa" />
Inicio da Frase
<input name="radio_pesqusa" type="radio" value="radio_pesqusa" />
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">
<tr>
<td width=""><div align="center" class="style3">
<div align="center" class="style7"><strong>SUA BUSCA NÃO RETORNOU RESULTADO!!</strong></div>
</div></td>
</tr>
<tr class="campo"><td width=""><div align="" class="style7">
<div align="center" class="style7">Codigo do Empresa </div>
</div></td>
<td width=""><div align="" class="style7">
<div align="center" class="style7">Codigo do Funcionario</div>
</div></td>
<td width=""><div align="" class="style7">
<div align="center" class="style7">Nome</div>
</div></td>
<td width=""><div align="" class="style7">
<div align="center" class="style7">E_mail</div>
</div></td>
<td width=""><div align="" class="style7">
<div align="center" class="style7">Codigo do Cargo </div>
</div></td>
<td width=""><div align="" class="style7">
<div align="center" class="style7">Login</div>
</div></td>
<td width=""><div align="" class="style7">
<div align="center" class="style7">Senha</div>
</div></td>
<td width=""><div align="" class="style7">
<div align="center" class="style7">Hora Inicial </div>
</div></td>
<td width=""><div align="" class="style7">
<div align="center" class="style7">Hora Final</div>
</div></td>
<td width=""><div align="" class="style7">
<div align="center" class="style7">Valor da Hora</div>
</div></td>
<td width=""><div align="" class="style7">
<div align="center" class="style7">Flg_Temporario</div>
</div></td>
</tr><%
SQL = "SELECT ID_EMPRESA, ID_FUNCIONARIO, NOME, EMAIL, ID_CARGO, LOGIN, SENHA, HORA_INI, HORA_FIM, VALOR_HORA, FLG_TEMPORARIO FROM FUNCIONARIO WHERE NOME LIKE '%"& Busca &"%' "%>
<tr class="style8">
<td height="" bgcolor="#FFFFFF"><strong><span class="syle8"><%=oRS_Busca("ID_EMPRESA")%></span></strong></td>
<td bgcolor="#FFFFFF"><strong><span class="style3 style6 style8"><%=oRS_Busca("ID_FUNCIONARIO")%></span></strong></td>
<td bgcolor="#FFFFFF"><strong><span class="style3 style6 style8"><%=oRS_Busca("NOME")%></span></strong></td>
<td bgcolor="#FFFFFF"><strong><span class="style3 style6 style8"><%=oRS_Busca("EMAIL")%></span></strong></td>
<td bgcolor="#FFFFFF"><strong><span class="style3 style6 style8"><%=oRS_Busca("ID_CARGO")%></span></strong></td>
<td bgcolor="#FFFFFF"><strong><span class="style3 style6 style8"><%=oRS_Busca("LOGIN")%></span></strong></td>
<td bgcolor="#FFFFFF"><strong><span class="style3 style6 style8"><%=oRS_Busca("SENHA")%></span></strong></td>
<td bgcolor="#FFFFFF"><strong><span class="style3 style6 style8"><%=oRS_Busca("HORA_INI")%></span></strong></td>
<td bgcolor="#FFFFFF"><strong><span class="style3 style6 style8"><%=oRS_Busca("HORA_FIM")%></span></strong></td>
<td bgcolor="#FFFFFF"><strong><span class="style3 style6 style8"><%=oRS_Busca("VALOR_HORA")%></span></strong></td>
<td bgcolor="#FFFFFF"><strong><span class="style3 style6 style8"><%=oRS_Busca("FLG_TEMPORARIO")%></span></strong></td>
</tr>
<td colspan="32" bgcolor="#FFFFFF"><div align="center">
<input name="BUSCAR" type="submit" class="botao" id="BUSCAR" value="BUSCAR" onclick="document.location = 'consu_new.asp'"/>
<input name="Limpar" type="button" class="botao" id="Limpar" value="Limpar"/>
</div></td>
<input name="acao2" type="hidden" id="acao2" value="buscar"/>
</tr>
</table>
</form>
</table></td>
</tr>
<tr>
<td height="" colspan="3" bgcolor="#265490"></td>
</tr>
</table>
</table>
</body>
</html>SE ALGUÉM TIVER UM CODIGO MAIS FÁCIL FICO GRATO.
Respostas
-
Tente jogar o include file no inicio do arquivo!
Dentro do arquivo conexao.asp, vc esta setando o objecto de conexao e o recordset?
Tipo:
Set conexao = Server.CreateObject("ADODB.Connection")
Set oRs_Busca = Server.CreateObejct("ADODB.Recordset")
Abraços
Estevam
Todas as Respostas
-
Emerson da maneira que voce esta fazendo voce devera tratar os parametros recebidos na pagina de busca e adequar o pesquisa SQL conforme os parametros passados. Por exemplo:
Digamos que o usuario passa o parametro "nome", "decrescente", "aleatorio", e o texto a ser pesquisado "Joao"
Ai no asp vc teria mais ou menos assim:
Dim tipopesquisa, tipoordem,tipobusca,valordapesquisa
tipopesquisa = "nome"
tipoordem = "decrescente"
tipobusca = "aleatorio"
valordapesquisa = "Joao"
SQL = "SELECT * FROM tabelabusca "
if tipopesquisa = "nome" then
SQL = SQL & " WHERE nome "
end if
if tipobusca = "aleatorioi then
SQL = SQL & " LIKE %'" & valordapesquisa & "%'"
if tipoordem = "decrescente" then
SQL = SQL & " ORDER BY DESC"
end if
Entao se os parametros passados forem diferentes voce deve criar novas instruçoes para os valores passados
Abraços
Estevam
-
To fazendo assim ?
<!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;
}
.style14 {font-size: 10px; color: #1C406C; font-family: Verdana, Arial, Helvetica, sans-serif; font-weight: bold; }
</style></head><body>
<table width="100%" 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="1" background="images/fd.jpg" bgcolor="#CCCCCC"><p> </p> </td>
<td width="79%" valign="top" bgcolor="#FFFFFF">
<form action="consu_new.asp" method="post" name="consu_new" id="acao" onSubmit="return valida();" >
<br />
<!--#include file="conexao.asp"-->
<%
Dim Campo_Pesquisa : Campo_Pesquisa = Request.Form("Pesquisa")
Dim Ordem : Ordem = Request.Form("radio_ordem")
Dim Pesquisa : Pesquisa = Request.Form("radio_pesquisa")
Dim acao : acao = Request.Form("acao")
Dim buscar_por : buscar_por = Request.Form("txt_Busca")
Dim oRS_Busca
%>
<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>Codigo</option>
<option>Nome</option>
</select> </td>
<td width="223" class="style7"> Ordem: <br />
<fieldset class="style8">
<input name="radio_ordem" type="radio" value="radio_ordem" />
Crescente
<input name="radio_ordem" type="radio" value="radio_ordem"/>
Decrescente
</fieldset></td>
</tr>
<tr>
<td class="style7">Pesquisa: <br />
<fieldset class="">
<input name="radio_pesqusa" type="radio" value="radio_pesqusa" />
Inicio da Frase
<input name="radio_pesqusa" type="radio" value="radio_pesqusa" />
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, ID_FUNCIONARIO, NOME, EMAIL, ID_CARGO, LOGIN, SENHA, HORA_INI, HORA_FIM, VALOR_HORA, FLG_TEMPORARIO FROM FUNCIONARIO WHERE NOME LIKE '%"& buscar_por &"%'"oRS_Busca.open SQL,conexao
if oRS_Busca.bof or oRS_Busca.eof then %>
<tr class="style8">
<td width="308"><div align="center" class="style3">
<div align="center" class="campo"><strong>SUA BUSCA NÃO RETORNOU RESULTADO!!</strong></div>
</div></td>
</tr>
<%else
if request.Form("txt_Busca") = "" then %>
<% End if
End if%>
<tr class="style8">
<td><div align="center" class="style3">
<div align="center" class="campo"><strong>PREENCHA O CAMPO!!</strong></div>
</div></td>
</tr>
</table>
<table width="" border="0" bgcolor="#E4E4E4">
<tr>
<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">Codigo Funcionario </span></strong></td>
<td width="" class="style7"><strong>E_mail</strong></td>
<td width="" class="style7"><strong><span class="style3 style6 style8">Codigo Cargo </span></strong></td>
<td width="" class="style7"><strong><span class="style3 style6 style8">Login</span></strong></td>
<td width="" class="style7"><strong><span class="style3 style6 style8">Senha</span></strong></td>
<td width="" class="style7"><strong><span class="style3 style6 style8">Filhos</span></strong></td>
<td width="" class="style7"><strong><span class="style3 style6 style8">Hora Inicial </span></strong></td>
<td width="" class="style7"><strong><span class="style3 style6 style8">Hora Final </span></strong></td>
<td width="" class="style7"><strong><span class="style3 style6 style8">Valor da Hora </span></strong></td>
<td width="" class="style14">Flg_Temporario</td>
</tr>
<tr class="style7">
<%
Do While oRS_Busca.Eof=false
%>
<td height="22" bgcolor="#FFFFFF" class="style7"><strong><span class="style3 style6 style8"><%=oRS_Busca("ID_EMPRESA")%></span></strong></td>
<td bgcolor="#FFFFFF" class="style7"><strong><span class="style3 style6 style8"><%=oRS_Busca("ID_FUNCONARIO")%></span></strong></td>
<td bgcolor="#FFFFFF" class="style7"><strong><span class="style3 style6 style8"><%=oRS_Busca("NOME")%></span></strong></td>
<td bgcolor="#FFFFFF" class="style7"><strong><span class="style3 style6 style8"><%=oRS_Busca("EMAIL")%></span></strong></td>
<td bgcolor="#FFFFFF" class="style7"><strong><span class="style3 style6 style8"><%=oRS_Busca("ID_CARGO")%></span></strong></td>
<td bgcolor="#FFFFFF" class="style7"><strong><span class="style3 style6 style8"><%=oRS_Busca("LOGIN")%></span></strong></td>
<td bgcolor="#FFFFFF" class="style7"><strong><span class="style3 style6 style8"><%=oRS_Busca("SENHA")%></span></strong></td>
<td bgcolor="#FFFFFF" class="style7"><strong><span class="style3 style6 style8"><%=oRS_Busca("HORA_INI")%></span></strong></td>
<td bgcolor="#FFFFFF" class="style7"><strong><span class="style3 style6 style8"><%=oRS_Busca("HORA_FIM")%></span></strong></td>
<td bgcolor="#FFFFFF" class="style7"><strong><span class="style3 style6 style8"><%=oRS_Busca("FLG_TEMPORARIO")%></span></strong></td>
<td bgcolor="#FFFFFF" class="style7"><strong><span class="style3 style6 style8"><%=oRS_Busca("porte_empresa")%></span></strong></td>
</tr>
<%
oRS_Busca.MoveNext
Loop
End If
%>
<tr>
<td height="22" colspan="11" 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>
mas ta com este erro porque ?
Microsoft VBScript runtime error '800a01c2'
Wrong number of arguments or invalid property assignment: 'conexao'
/Chamado/consu_new.asp, line 181
-
Tente jogar o include file no inicio do arquivo!
Dentro do arquivo conexao.asp, vc esta setando o objecto de conexao e o recordset?
Tipo:
Set conexao = Server.CreateObject("ADODB.Connection")
Set oRs_Busca = Server.CreateObejct("ADODB.Recordset")
Abraços
Estevam
-
Já fiz isso conexão ta ok..agora .
Fiz assim SET RS_BUSCA = conexao.execute(SQL)
.
Porém quando eu digito o que eu quero buscar ele não traz nada !!
olha o codigo que executa...
<%
IF acao = "buscar" THEN
SQL = "SELECT ID_EMPRESA, ID_FUNCIONARIO, NOME, EMAIL, ID_CARGO, LOGIN, SENHA, HORA_INI, HORA_FIM, VALOR_HORA, FLG_TEMPORARIO FROM FUNCIONARIO WHERE NOME LIKE '%"&buscar_por&"%'"SET RS_BUSCA = conexao.execute(SQL)
'RS_BUSCA.open SQL,conexao
if RS_BUSCA.bof or RS_BUSCA.eof then %>
<tr class="style8">
<td width="308"><div align="center" class="style3">
<div align="center" class="campo"><strong>SUA BUSCA NÃO RETORNOU RESULTADO!!</strong></div>
</div></td>
</tr>
<%else
if request.Form("txt_Busca") = "" then %>
<% End if
End if%>
</table>
<table width="" border="0" bgcolor="#E4E4E4">
<tr>
<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">Codigo Funcionario </span></strong></td>
<td width="" class="style7"><strong>E_mail</strong></td>
<td width="" class="style7"><strong><span class="style3 style6 style8">Codigo Cargo </span></strong></td>
<td width="" class="style7"><strong><span class="style3 style6 style8">Login</span></strong></td>
<td width="" class="style7"><strong><span class="style3 style6 style8">Senha</span></strong></td>
<td width="" class="style7"><strong><span class="style3 style6 style8">Filhos</span></strong></td>
<td width="" class="style7"><strong><span class="style3 style6 style8">Hora Inicial </span></strong></td>
<td width="" class="style7"><strong><span class="style3 style6 style8">Hora Final </span></strong></td>
<td width="" class="style7"><strong><span class="style3 style6 style8">Valor da Hora </span></strong></td>
<td width="" class="style14">Flg_Temporario</td>
</tr>
<tr class="style7">
<%
Do While RS_BUSCA.Eof=false
%>
<td height="22" bgcolor="#FFFFFF" class="style7"><strong><span class="style3 style6 style8"><%=RS_BUSCA("ID_EMPRESA")%></span></strong></td>
<td bgcolor="#FFFFFF" class="style7"><strong><span class="style3 style6 style8"><%=RS_BUSCA("ID_FUNCONARIO")%></span></strong></td>
<td bgcolor="#FFFFFF" class="style7"><strong><span class="style3 style6 style8"><%=RS_BUSCA("NOME")%></span></strong></td>
<td bgcolor="#FFFFFF" class="style7"><strong><span class="style3 style6 style8"><%=RS_BUSCA("EMAIL")%></span></strong></td>
<td bgcolor="#FFFFFF" class="style7"><strong><span class="style3 style6 style8"><%=RS_BUSCA("ID_CARGO")%></span></strong></td>
<td bgcolor="#FFFFFF" class="style7"><strong><span class="style3 style6 style8"><%=RS_BUSCA("LOGIN")%></span></strong></td>
<td bgcolor="#FFFFFF" class="style7"><strong><span class="style3 style6 style8"><%=RS_BUSCA("SENHA")%></span></strong></td>
<td bgcolor="#FFFFFF" class="style7"><strong><span class="style3 style6 style8"><%=RS_BUSCA("HORA_INI")%></span></strong></td>
<td bgcolor="#FFFFFF" class="style7"><strong><span class="style3 style6 style8"><%=RS_BUSCA("HORA_FIM")%></span></strong></td>
<td bgcolor="#FFFFFF" class="style7"><strong><span class="style3 style6 style8"><%=RS_BUSCA("FLG_TEMPORARIO")%></span></strong></td>
<td bgcolor="#FFFFFF" class="style7"><strong><span class="style3 style6 style8"><%=RS_BUSCA("porte_empresa")%></span></strong></td>
</tr>
<%
RS_BUSCA.MoveNext
Loop
End If
%>
<tr>
<td height="22" colspan="11" 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> -
-
-
-
Não aparece nenhum erro
Olha o cod ..
<!--#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
%>
<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>Codigo</option>
<option>Nome</option>
</select> </td>
<td width="223" class="style7"> Ordem: <br />
<fieldset class="style8">
<input name="radio_ordem" type="radio" value="radio_ordem" />
Crescente
<input name="radio_ordem" type="radio" value="radio_ordem"/>
Decrescente
</fieldset></td>
</tr>
<tr>
<td class="style7">Pesquisa: <br />
<fieldset class="">
<input name="radio_pesqusa" type="radio" value="radio_pesqusa" />
Inicio da Frase
<input name="radio_pesqusa" type="radio" value="radio_pesqusa" />
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, ID_FUNCIONARIO, NOME, EMAIL, ID_CARGO, LOGIN, SENHA, HORA_INI, HORA_FIM, VALOR_HORA, FLG_TEMPORARIO FROM FUNCIONARIO WHERE NOME LIKE '%"&buscar_por&"%'"SET RS_BUSCA = conexao.execute(SQL)
'RS_BUSCA.open SQL,conexao
if RS_BUSCA.bof or RS_BUSCA.eof then %>
<tr class="style8">
<td width="308"><div align="center" class="style3">
<div align="center" class="campo"><strong>SUA BUSCA NÃO RETORNOU RESULTADO!!</strong></div>
</div></td>
</tr>
<%else
' if request.Form("txt_Busca") = "" then %>
<% ' End if
End if%>
</table>
<table width="" border="0" bgcolor="#E4E4E4">
<tr>
<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">Codigo Funcionario </span></strong></td>
<td width="" class="style7"><strong>E_mail</strong></td>
<td width="" class="style7"><strong><span class="style3 style6 style8">Codigo Cargo </span></strong></td>
<td width="" class="style7"><strong><span class="style3 style6 style8">Login</span></strong></td>
<td width="" class="style7"><strong><span class="style3 style6 style8">Senha</span></strong></td>
<td width="" class="style7"><strong><span class="style3 style6 style8">Filhos</span></strong></td>
<td width="" class="style7"><strong><span class="style3 style6 style8">Hora Inicial </span></strong></td>
<td width="" class="style7"><strong><span class="style3 style6 style8">Hora Final </span></strong></td>
<td width="" class="style7"><strong><span class="style3 style6 style8">Valor da Hora </span></strong></td>
<td width="" class="style14">Flg_Temporario</td>
</tr>
<tr class="style7">
<%
Do While RS_BUSCA.Eof=false
%>
<td height="22" 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("ID_FUNCONARIO")%></span></strong></td>
<td bgcolor="#FFFFFF" class="style7"><strong><span class="style8"><%=RS_BUSCA("NOME")%></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("ID_CARGO")%></span></strong></td>
<td bgcolor="#FFFFFF" class="style7"><strong><span class="style8"><%=RS_BUSCA("LOGIN")%></span></strong></td>
<td bgcolor="#FFFFFF" class="style7"><strong><span class="style8"><%=RS_BUSCA("SENHA")%></span></strong></td>
<td bgcolor="#FFFFFF" class="style7"><strong><span class="style8"><%=RS_BUSCA("HORA_INI")%></span></strong></td>
<td bgcolor="#FFFFFF" class="style7"><strong><span class="style8"><%=RS_BUSCA("HORA_FIM")%></span></strong></td>
<td bgcolor="#FFFFFF" class="style7"><strong><span class="style8"><%=RS_BUSCA("FLG_TEMPORARIO")%></span></strong></td>
<td bgcolor="#FFFFFF" class="style7"><strong><span class="style8"><%=RS_BUSCA("porte_empresa")%></span></strong></td>
</tr>
<%
RS_BUSCA.MoveNext
Loop
End If
%>
<tr>
<td height="22" colspan="11" 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>
Fiz uma função javascript para validar o campo
function validar(){
consulta.txt_Busca.focus(document.consulta.txt_Busca.style.background ="");
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>Então como que eu faço também para só aparecer está resposta
SUA BUSCA NÃO RETORNOU RESULTADO!!
quando ele voltar da consulta do banco .
-
olha Estavam então consegui, fazer a busca pelo campo texto.
Mas como que eu posso fazer a busca pelo combobox, fazer por ordem crescente e descrescente e também pesquisa pela frase inicial e frase aleatório..
olha como ficou o cod !!
<!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="100%" 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">function validar(){
consulta.txt_Busca.focus(document.consulta.txt_Busca.style.background ="");
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>
<form id="consulta" name="consulta" method="post" action="consu_empresa.asp" onSubmit="return validar();">
<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
%>
<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>Codigo</option>
<option>Nome</option>
</select>
</td>
<td width="223" class="style7"> Ordem: <br />
<fieldset class="style8">
<input name="radio_ordem" type="radio" value="radio_ordem" />
Crescente
<input name="radio_ordem" type="radio" value="radio_ordem"/>
Decrescente
</fieldset></td>
</tr>
<tr>
<td class="style7">Pesquisa: <br />
<fieldset class="">
<input name="radio_pesqusa" type="radio" value="radio_pesqusa" />
Inicio da Frase
<input name="radio_pesqusa" type="radio" value="radio_pesqusa" />
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 WHERE NOME_FANTASIA LIKE '%"&buscar_por&"%'"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>