Foros del Web » Programando para Internet » ASP Clásico »

[SOLUCIONADO] Tablas y directorio asp

Estas en el tema de Tablas y directorio asp en el foro de ASP Clásico en Foros del Web. hola buen dia tengo un buscador en asp necesito su ayuda necesito que me busque por area y extencion lo que pasa ES QUE UNICAMENTE ...
  #1 (permalink)  
Antiguo 04/06/2012, 10:22
 
Fecha de Ingreso: mayo-2012
Mensajes: 18
Antigüedad: 11 años, 11 meses
Puntos: 0
Pregunta Tablas y directorio asp

hola buen dia
tengo un buscador en asp necesito su ayuda necesito que me busque por area y extencion lo que pasa ES QUE UNICAMENTE LO ESTA BUSCANDO POR NOMBRE. y no puedo hacer que mis resultados me los ponga en una tabla
gracias muchas gracias
<html>
<head>
<title>Buscar</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<%
Dim buscar
buscar = Request.Form("nombre")
%>

<body bgcolor="#FFFFFF" text="#000000"><center>
<p><b><font size="5">BUSCADOR</font></b> </p>
<%
Function fBuscar(cnn)
Dim rs
Dim v_sql
Dim str
v_sql="SELECT Nombre, Area, Extension, Email FROM buscame_directorio WHERE Nombre LIKE '%" + buscar + "%'"

Set rs = CreateObject("ADODB.Recordset")
rs.ActiveConnection = cnn
rs.Open v_sql
While Not rs.EOF
str = str & "<A Class='t5' Href='" & rs("Nombre") & "'>" & rs("Area") & rs("Extension") & " >> <br>" & "</a>" & rs("Nombre")& rs("Area")& rs("Extension")& rs("Email")& "<BR> <BR>"

rs.MoveNext
Wend
if str = "" then str ="<CENTER><B>Lo siento, no se encontraron resultados</B></CENTER>"
if buscar = "" then str ="<CENTER><B>Por favor, especifique su búsqueda</B></CENTER>"
fBuscar = str
End Function

Dim cnn
Dim str
Dim DBName
DBName = "Provider=SQLOLEDB.1;Persist Security Info=true;User ID=formacion;Password=;Initial Catalog=dde;Data Source=LMSPROD1"
Set cnn = Server.CreateObject("ADODB.Connection")
cnn.Open DBName
Set rs = CreateObject("ADODB.Recordset")
rs.ActiveConnection = cnn

Response.write "<FONT COLOR=Red "
Response.write "SIZE=4 FACE=Arial> "
Response.write "Resultados "
Response.write "de la busqueda: <P>"
Response.write "</FONT> "
Response.write "<FONT COLOR=Green "
Response.write "SIZE=3 FACE=Arial> "
Response.Write fbuscar(cnn)
Response.write "</FONT><hr> "
%>
<form name="form1" method="post" action="buscador.asp">
<input name="nombre" type="text" id="nombre">
<input type="submit" name="Submit" value="Buscar!">
</form></center>
</body>
</html>
  #2 (permalink)  
Antiguo 04/06/2012, 13:51
Avatar de JuanRAPerez
Colaborador
 
Fecha de Ingreso: octubre-2003
Mensajes: 2.393
Antigüedad: 20 años, 6 meses
Puntos: 27
Respuesta: Tablas y directorio asp

ordena un poco mas tu codigo
en lugar de usar la función halo directamente

+ recoge la variable
+ crea la sql con la variable
+ abre la base de datos
+ dentro del While imprime los registros
+ cierra la base
__________________
JuanRa Pérez
San Salvador, El Salvador
  #3 (permalink)  
Antiguo 05/06/2012, 09:39
 
Fecha de Ingreso: mayo-2012
Mensajes: 18
Antigüedad: 11 años, 11 meses
Puntos: 0
Respuesta: Tablas y directorio asp

Hola mira lo genere por record set con un html pones un nombre y mi .asp se quedo asi ya te da los nombres de los que busco ahora estoy intentando buscarlos por extencion con otra cajita de texto. Verificando el codigo tengo quer agregar un If pero aun no c bien por donde jajaja.
Muchas gracias

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/conexion.asp" -->
<%
Dim Recordset1__MMColParam
Recordset1__MMColParam = "1"
If (Request.Form("nombre") <> "") Then
Recordset1__MMColParam = Request.Form("nombre")
End If
%>
<%
Dim Recordset1
Dim Recordset1_numRows

Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_conexion_STRING
Recordset1.Source = "SELECT Nombre, Area, Extension, Email FROM buscame_directorio WHERE Nombre LIKE '%" + Recordset1__MMColParam + "%'"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()

Recordset1_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = -1
Repeat1__index = 0
Recordset1_numRows = Recordset1_numRows + Repeat1__numRows
%>
<!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>Directorio - Buscame</title>
<script type="text/JavaScript">
<!--
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
var i,p,q,nm,test,num,min,max,errors='',args=MM_valida teForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
if (val) { nm=val.name; if ((val=val.value)!="") {
if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
} else if (test!='R') { num = parseFloat(val);
if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' es requerido.\n'; }
} if (errors) alert('error:\n'+errors);
document.MM_returnValue = (errors == '');
}
//-->
</script>
<style type="text/css">
<!--
body {
background-color: #ededed;
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
.style2 {font-family: Verdana, Arial, Helvetica, sans-serif; font-weight: bold; font-size: 12px; }
.style3 {font-size: 11px; font-family: Verdana, Arial, Helvetica, sans-serif;}
a:link {
color: #FF0000;
text-decoration: underline;
}
a:visited {
text-decoration: underline;
color: #FF0000;
}
a:hover {
text-decoration: none;
color: #FF0000;
}
a:active {
text-decoration: underline;
color: #FF0000;
}
-->
</style></head>

<body onLoad="document.form1.nombre.focus();">
<table width="100%" border="0" cellspacing="10" cellpadding="5" bgcolor="#FFFFFF">
<tr>
<td><img src="media/logo1.gif" width="178" height="68" /></td>
<td><img src="media/spacer.gif" width="20" height="20" /></td>
<td width="100%"><div align="right"><img src="media/logo2.gif" width="169" height="58" /></div></td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#666666">
<tr>
<td width="100%"><img src="media/spacer2.gif" width="20" height="5" /></td>
</tr>
</table>
<p>&nbsp;</p>
<table width="90%" border="1" align="center" cellpadding="5" cellspacing="0" bordercolor="#999999" bgcolor="#FFFFFF">
<tr>
<td bgcolor="#CCCCCC"><center spry:hover="style2" class="style2">
Nombre
</center></td>
<td bgcolor="#CCCCCC"><center spry:hover="style2" class="style2">
&Aacute;rea
</center></td>
<td bgcolor="#CCCCCC"><center class="style2">
<p class="style2">Extensi&oacute;n </p>
</center></td>
<td bgcolor="#CCCCCC"><center spry:hover="style2" class="style2">
email
</center></td>
</tr>
<%
While ((Repeat1__numRows <> 0) AND (NOT Recordset1.EOF))
%>
<tr>
<td class="style3"><%=(Recordset1.Fields.Item("Nombre" ).Value)%></td>
<td class="style3"><%=(Recordset1.Fields.Item("Area"). Value)%></td>
<td class="style3"><%=(Recordset1.Fields.Item("Extensi on").Value)%></td>
<td><a href="mailto:<%=(Recordset1.Fields.Item("Email").V alue)%>"><%=(Recordset1.Fields.Item("Email").Value )%></a></td>
</tr>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
Recordset1.MoveNext()
Wend
%>
</table>
<form action="buscador2.asp" method="post" name="form1" id="form1" onsubmit="MM_validateForm('nombre','','R');return document.MM_returnValue">
<blockquote>
<p>
<input name="nombre" type="text" id="nombre" />
<img src="media/spacer.gif" width="20" height="20" />
<input type="submit" name="Submit" value="Buscar" />
</p>
</blockquote>
</form>
</body>
</html>
<%
Recordset1.Close()
Set Recordset1 = Nothing
%>

Etiquetas: asp, directorio, recordset, server, sql, tabla, tablas
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 12:48.