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

Ayuda con busqueda

Estas en el tema de Ayuda con busqueda en el foro de ASP Clásico en Foros del Web. Saludos aqui nuevamente agradeciendo la ayuda que me proporcionaron ya logre conectar mi base de datos sql con una pequeña base y cargar los registros ...
  #1 (permalink)  
Antiguo 08/03/2006, 09:29
 
Fecha de Ingreso: diciembre-2003
Mensajes: 595
Antigüedad: 21 años, 4 meses
Puntos: 1
Ayuda con busqueda

Saludos aqui nuevamente agradeciendo la ayuda que me proporcionaron ya logre conectar mi base de datos sql con una pequeña base y cargar los registros en text field, ahora lo que no puedo hacer y estoy atorado en en una busqueda sencilla veran agrege a la pantalla un boton y un textfield para que al hacer una busqueda ya sea por id de la tabla me llame esa informacion a los text field que tengo alli esto es lo que tengo espero alguien me pueda ayduar y gracias de antemano.

<%
' conexion con la base de datos
dim conn
Set conn = Server.CreateObject("ADODB.Connection")
conn.ConnectionString ="driver=SQL Server;server=DESARROLLO;uid=prueba;pwd=prueba;dat abase=EXTERNA"
conn.Open

' variable para meter las busquedas
dim sql
sql = "select * from prueba"

' variable con la cual se hace la conexion
dim rs
set rs = Server.CreateObject("ADODB.Recordset")
rs.Open sql,conn

' variable para uasrlo en el list
dim datos
datos = request.form("lista")

%>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>buscar</title>
<style type="text/css">
<!--
body,td,th {
color: #FFFFFF;
}
body {
background-color: #003333;
}
-->
</style></head>

<body>

<form name="form2" method="post" action="">
<div align="center">
<input type="submit" name="Submit" value="Buscar">
<input type="text" name="textfield">
</div>
</form>
<p>&nbsp;</p>
<form id="form1" name="form1" method="post" action="">
<label><br>
ID
<input type="text" name="txtid" value='<% =rs("id") %>'/>
</label>
<div align="left"></div>
<p align="left">NOMBRE
<input type="text" name="txtnombre" value='<% =rs("nombre") %>'/>
PUESTO
<input type="text" name="txtpuesto" value='<% =rs("puesto") %>'/>
AREA
<input type="text" name="txtarea" value='<% =rs("area") %>'/>
</p>
<p>TELEFONO
<input type="text" name="txttelefono" value='<% =rs("telefono") %>'/></p>
SUELDO
<input type="text" name="txtsueldo" value='<% =rs("sueldo") %>'/>
FECHA
<input type="text" name="txtfecha" value='<% =rs("fecha_ingreso") %>'/>
TURNO
<input type="text" name="txtturno" value='<% =rs("turno") %>'/>
</form>


</body>
</html>
  #2 (permalink)  
Antiguo 08/03/2006, 10:09
Avatar de ElAprendiz  
Fecha de Ingreso: enero-2002
Ubicación: Maipu, Chile
Mensajes: 3.706
Antigüedad: 23 años, 3 meses
Puntos: 2
haces las busquedas por id?...
debes hacerlas por un campo como nombre o puesto
  #3 (permalink)  
Antiguo 08/03/2006, 11:17
Avatar de a n g e l u s  
Fecha de Ingreso: enero-2006
Ubicación: Chile
Mensajes: 237
Antigüedad: 19 años, 3 meses
Puntos: 1
EN REALIDAD LO QUE HACES NO ES CONVENIENTE, LA BUSQUEDA POR ID NO TE CONVIENE, TE SUGUIERO ALGUN NUMERO DE ASIGNACION O ALGO ASI, PERO AQUI ESTA TU RESPUESTA....

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>buscar</title>
<style type="text/css">
<!--
body,td,th {
color: #FFFFFF;
}
body {
background-color: #003333;
}
-->
</style></head>

<body>

<form name="form2" method="post" action="">
<div align="center">
<input type="submit" name="Submit" value="Buscar">
<input type="text" name="buscado">
</div>
</form>
<p>&nbsp;</p>

<hr>

<%
if request("buscado") <> "" then
dim conn
Set conn = Server.CreateObject("ADODB.Connection")
conn.ConnectionString ="driver=SQL Server;server=DESARROLLO;uid=prueba;pwd=prueba;dat abase=EXTERNA"
conn.Open

sql = "select * from prueba where id= "& request("buscado")
set rs = conn.execute(sql)

if not rs.eof then
%>
<form id="form1" name="form1" method="post" action="">
<label><br>
ID
<input type="text" name="txtid" value='<% =rs("id") %>'/>
</label>
<div align="left"></div>
<p align="left">NOMBRE
<input type="text" name="txtnombre" value='<% =rs("nombre") %>'/>
PUESTO
<input type="text" name="txtpuesto" value='<% =rs("puesto") %>'/>
AREA
<input type="text" name="txtarea" value='<% =rs("area") %>'/>
</p>
<p>TELEFONO
<input type="text" name="txttelefono" value='<% =rs("telefono") %>'/></p>
SUELDO
<input type="text" name="txtsueldo" value='<% =rs("sueldo") %>'/>
FECHA
<input type="text" name="txtfecha" value='<% =rs("fecha_ingreso") %>'/>
TURNO
<input type="text" name="txtturno" value='<% =rs("turno") %>'/>
</form>
<%
else
response.write "<center>Datos no encontrados</center>"
end if
else
response.write "<center>Ingrese un numero a buscar</center>"
end if
%>
</body>
</html>
__________________
Atte,
A n g e l u s
Concepción - Chile
más vale respuestas bien pensadas, que 7000 post
  #4 (permalink)  
Antiguo 08/03/2006, 11:28
 
Fecha de Ingreso: diciembre-2003
Mensajes: 595
Antigüedad: 21 años, 4 meses
Puntos: 1
Cita:
Iniciado por a n g e l u s
EN REALIDAD LO QUE HACES NO ES CONVENIENTE, LA BUSQUEDA POR ID NO TE CONVIENE, TE SUGUIERO ALGUN NUMERO DE ASIGNACION O ALGO ASI, PERO AQUI ESTA TU RESPUESTA....

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>buscar</title>
<style type="text/css">
<!--
body,td,th {
color: #FFFFFF;
}
body {
background-color: #003333;
}
-->
</style></head>

<body>

<form name="form2" method="post" action="">
<div align="center">
<input type="submit" name="Submit" value="Buscar">
<input type="text" name="buscado">
</div>
</form>
<p>&nbsp;</p>

<hr>

<%
if request("buscado") <> "" then
dim conn
Set conn = Server.CreateObject("ADODB.Connection")
conn.ConnectionString ="driver=SQL Server;server=DESARROLLO;uid=prueba;pwd=prueba;dat abase=EXTERNA"
conn.Open

sql = "select * from prueba where id= "& request("buscado")
set rs = conn.execute(sql)

if not rs.eof then
%>
<form id="form1" name="form1" method="post" action="">
<label><br>
ID
<input type="text" name="txtid" value='<% =rs("id") %>'/>
</label>
<div align="left"></div>
<p align="left">NOMBRE
<input type="text" name="txtnombre" value='<% =rs("nombre") %>'/>
PUESTO
<input type="text" name="txtpuesto" value='<% =rs("puesto") %>'/>
AREA
<input type="text" name="txtarea" value='<% =rs("area") %>'/>
</p>
<p>TELEFONO
<input type="text" name="txttelefono" value='<% =rs("telefono") %>'/></p>
SUELDO
<input type="text" name="txtsueldo" value='<% =rs("sueldo") %>'/>
FECHA
<input type="text" name="txtfecha" value='<% =rs("fecha_ingreso") %>'/>
TURNO
<input type="text" name="txtturno" value='<% =rs("turno") %>'/>
</form>
<%
else
response.write "<center>Datos no encontrados</center>"
end if
else
response.write "<center>Ingrese un numero a buscar</center>"
end if
%>
</body>
</html>

Gracias por tu ayuda me sacaste del oyo
  #5 (permalink)  
Antiguo 08/03/2006, 14:07
 
Fecha de Ingreso: diciembre-2003
Mensajes: 595
Antigüedad: 21 años, 4 meses
Puntos: 1
Cita:
Iniciado por a n g e l u s
EN REALIDAD LO QUE HACES NO ES CONVENIENTE, LA BUSQUEDA POR ID NO TE CONVIENE, TE SUGUIERO ALGUN NUMERO DE ASIGNACION O ALGO ASI, PERO AQUI ESTA TU RESPUESTA....

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>buscar</title>
<style type="text/css">
<!--
body,td,th {
color: #FFFFFF;
}
body {
background-color: #003333;
}
-->
</style></head>

<body>

<form name="form2" method="post" action="">
<div align="center">
<input type="submit" name="Submit" value="Buscar">
<input type="text" name="buscado">
</div>
</form>
<p>&nbsp;</p>

<hr>

<%
if request("buscado") <> "" then
dim conn
Set conn = Server.CreateObject("ADODB.Connection")
conn.ConnectionString ="driver=SQL Server;server=DESARROLLO;uid=prueba;pwd=prueba;dat abase=EXTERNA"
conn.Open

sql = "select * from prueba where id= "& request("buscado")
set rs = conn.execute(sql)

if not rs.eof then
%>
<form id="form1" name="form1" method="post" action="">
<label><br>
ID
<input type="text" name="txtid" value='<% =rs("id") %>'/>
</label>
<div align="left"></div>
<p align="left">NOMBRE
<input type="text" name="txtnombre" value='<% =rs("nombre") %>'/>
PUESTO
<input type="text" name="txtpuesto" value='<% =rs("puesto") %>'/>
AREA
<input type="text" name="txtarea" value='<% =rs("area") %>'/>
</p>
<p>TELEFONO
<input type="text" name="txttelefono" value='<% =rs("telefono") %>'/></p>
SUELDO
<input type="text" name="txtsueldo" value='<% =rs("sueldo") %>'/>
FECHA
<input type="text" name="txtfecha" value='<% =rs("fecha_ingreso") %>'/>
TURNO
<input type="text" name="txtturno" value='<% =rs("turno") %>'/>
</form>
<%
else
response.write "<center>Datos no encontrados</center>"
end if
else
response.write "<center>Ingrese un numero a buscar</center>"
end if
%>
</body>
</html>

Disculpa por volver a molestar ya estuve probando la busqueda que me diste y la cambie para que me de el folio que es strin en vez del ID ahora tengo una pregunta en la pantalla agrege otro text fiel debajo del boton de busqueda para agregar otro criterio de busqueda que al oprimir el boton de busqueda tome el valor abuscar ya sea del folio en el text fiel1 o el valor del id en el text fiel 2 con el mismo boton no se si aqui se pueda usar algun case o algo asi pues yo lo usaba con vb el codigo que tengo en la pantalla es este



<%
DIM conn
Set conn = Server.CreateObject("ADODB.Connection")
conn.ConnectionString ="driver=SQL Server;server=DESARROLLO;uid=prueba;pwd=prueba;dat abase=EXTERNA"
conn.Open

DIM sql

%>



<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>base</title>
<style type="text/css">
<!--
body,td,th {
color: #FFFFFF;
}
body {
background-color: #003366;
}
-->
</style></head>

<body>


<form name="form2" method="post" action="">
<div align="center">
<p>
<input type="submit" name="Submit" value="Buscar">
</p>
<p>Folio
<input type="text" name="buscado">
ID
<input name="id" type="text" id="id">
</p>
</div>
</form>


<%

select case request
case "buscado"
sql = "select * from prueba where folio like '"& request("buscado") &"'"
set rs = conn.execute(sql)

case "id"
sql = "select * from prueba where folio like '"& request("id") &"'"
set rs = conn.execute(sql)

end select



if not rs.eof then

%>



<p>&nbsp;</p>
<p>&nbsp;</p>
<form id="form1" name="form1" method="post" action="">
<label>ID
<input type="text" name="txtid" value='<% =rs("folio") %>'/>
</label>
NOMBRE
<input type="text" name="txtnombre" value='<% =rs("nombre") %>'/>
PUESTO
<input type="text" name="txtpuesto" value='<% =rs("puesto") %>'/>
AREA
<input type="text" name="txtarea" value='<% =rs("area") %>'/>
<p>TELEFONO
<input type="text" name="txttelefono" value='<% =rs("telefono") %>'/></p>
SUELDO
<input type="text" name="txtsueldo" value='<% =rs("sueldo") %>'/>
FECHA
<input type="text" name="txtfecha" value='<% =rs("fecha_ingreso") %>'/>
TURNO
<input type="text" name="txtturno" value='<% =rs("turno") %>'/>
</form>
<form name="form2" method="post" action="">
<div align="center"></div>
</form>


<%

else
response.write "<center>Datos no encontrados</center>"
end if

%>


</body>


<%
Set rs = Nothing
conn.Close
Set conn = Nothing
%>


</html>




pero usando el case asi me aroja error no se si lo este usando adecuadamente

Última edición por hunabku; 08/03/2006 a las 14:20
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 16:29.