Ver Mensaje Individual
  #1 (permalink)  
Antiguo 26/05/2005, 15:51
Avatar de kyo1982
kyo1982
 
Fecha de Ingreso: mayo-2005
Mensajes: 71
Antigüedad: 20 años
Puntos: 0
Pregunta Busqueda En Asp

hola amigos tengo un problemita necesito hacer una busqueda de unos productos en una base de datos, a traves de que el suario tipee el mismo.

para capturar el producto utilizo un archvo html y para la busqueda asp, lo hago con sql server.

la tabla se llama maestro (donde estan los productos), pero me manda error ayudenme please.

EL CODIGO DEL HTML ES ESTE
*******************************
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Documento sin t&iacute;tulo</title>
<style type="text/css">
<!--
.Estilo1 { font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
}
-->
</style>
</head>
<form method="Post" action="buscar.asp">
<body>
</p>
<table width="617" border="0" align="center">
<tr>
<th scope="row"><table width="605" border="1">
<tr>
<th colspan="2" scope="row"><span class="Estilo1">Bienvenido </span></th>
</tr>
<tr>
<th colspan="2" bgcolor="#DC2B19" scope="row">&nbsp;</th>
</tr>
<tr>
<th width="250" scope="row"><div align="right"><span class="Estilo1">Codigo de Cliente </span></div></th>
<th width="339" scope="row"><div align="left">
<input type="text" name="palabra" size="20">
</div></th>
</tr>
<tr>
<th colspan="2" scope="row"><input type="submit" value="Buscar" name="boton1"></th>
</tr>
</table></th>
</tr>
</table>
<p align="center">&nbsp;</p>
<p align="center">
</form>
</body>
</html>

*******************************


EL CODIGO DEL ASP ES ESTE
************************************

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/galope.asp" -->
<%
Dim busqueda
Dim busqueda_numRows

Set busqueda = Server.CreateObject("ADODB.Recordset")
busqueda.ActiveConnection = MM_galope_STRING
busqueda.Source = "SELECT * FROM dbo.MAESTRO"
busqueda.CursorType = 0
busqueda.CursorLocation = 2
busqueda.LockType = 1
busqueda.Open()

busqueda_numRows = 0
%>

<%
Dim Temp
'Creamos la sentencia SQL que extrae de la base las páginas que tienen la palabra que buscamos
'buscando con el operador LIKE obtenemos apariciones del substring escrito en el formulario, entre las palabras clave

Temp="Select * From MAESTRO Where cod_cliente like '%" & UCase(Request("palabra")) & "%'"

Tabla.Open Temp, Conexion
If MAESTRO.BOF And MAESTRO.EOF Then
%>
'si no encuentra nada nos da este mensaje
<p><font face="Tahoma" size="2">No se ha encontrado nada con <strong><%=Request("palabra")%></strong> en la Base de Datos</font></p>
<%
Else
'aquí comienza el Script que nos muestra los resultados,
'si los encuentra en la tabla
%>
<div align="center"><center>
<table border="1" cellpadding="0" cellspacing="0" width="100%" height="74" bordercolor="#C0C0C0">
<tr>
<td width="22%" height="19">
<p align="center"><strong><font face="Tahoma" size="2">Categoria</font></strong>
</td>
<td width="22%" height="19">
<p align="center"><strong><font face="Tahoma" size="2">Nombre de la pagina</font></strong></p>
</td>
<td width="30%" height="19">
<p align="center"><strong><font face="Tahoma" size="2">Descripcion</font></strong>
</td>
</tr>
<% While Not TAB_PDA_EB_MAESTRO.EOF%>
<tr>
<td width="22%" bgcolor="#FFCC00" height="51">
<p align="center"><font face="Tahoma" size="2"><%=MAESTRO.Fields("cod_cuenta")%></font></td>
<td width="22%" bgcolor="#FFCC00" height="51">
<p align="center"><font face="Tahoma" size="2"><%=MAESTRO.Fields("fecha")%></font></td>
<td width="30%" bgcolor="#FFCC00" height="51">
<p align="center"><font face="Tahoma" size="2"><%=MAESTRO.Fields("distribucion")%></font></td>
</table>
</center></div>
<p align="center">&nbsp;</p>
<p align="center"> </p>
</body>
</html>
<%
busqueda.Close()
Set busqueda = Nothing
%>
</body>
</html>