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

ultima duda

Estas en el tema de ultima duda en el foro de ASP Clásico en Foros del Web. <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%> <!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>Documento sin t&iacute;tulo</title> </head> <body> <table width="200" ...
  #1 (permalink)  
Antiguo 07/11/2007, 22:24
 
Fecha de Ingreso: noviembre-2007
Mensajes: 17
Antigüedad: 17 años, 6 meses
Puntos: 1
ultima duda

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!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>Documento sin t&iacute;tulo</title>
</head>

<body>
<table width="200" border="0" align="center" name="logo" noresize>
<tr>
<td>
<p align="center">
<img src="imagenes/LOGO.GIF"/>
</p>
</td>
</tr>
</table>
<p>&nbsp;</p>
<p>Buscador de Productos</p>
<%dim marca, precio, tipo, oferta, producto
marca = request.form("marca")
precio = cint(request.form("precio"))
tipo = request.form("tipo")
oferta = cint(request.form("oferta"))
variable_lista = request.querystring("lista")
variable_producto = request.querystring("producto")

response.write "el valor de lista es: " & variable_lista
response.write "<br />"
response.write "el valor de producto es: " & variable_producto


Dim Conexion, SQL
Set Conexion = Server.CreateObject("ADODB.Connection")
Set Rs = Server.CreateObject("ADODB.Recordset")
Conexion.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("basededatos/bdprueba.mbd.mdb")

SQL="SELECT ID_Prod, Tipo_Prod, Oferta_Prod, Marca_prod, Precio_prod FROM Tabla"
Set Rs = Conexion.execute(SQL)

%>
<table width="400" border="1">
<tr>
<td>ID Producto</td>
<td>Tipo Producto</td>
<td>Oferta Producto</td>
<td>Marca producto</td>
<td>Precio producto</td>
</tr>
<%
if(variable_lista = 1 and variable_producto = 1) then
do while not Rs.eof
if(Oferta_Prod = 0) then
%>
<tr>
<td><% = Rs(0) %></td>
<td><% = Rs(1) %></td>
<td><% = Rs(2) %></td>
<td><% = Rs(3) %></td>
<td><% = Rs(4) %></td>
</tr>
<%
Rs.movenext
end if
loop
else
response.write "No existen registros asociados"
end if
%>
</table>

<h3 align="center">
<%
Conexion.execute(SQL)
Conexion.Close
Set Conexion = nothing
%>

<br />
<br />
<br />

<a href="default.asp">Volver </a></h3>
</body>
</html>


bueno ahora la duda en el codigo que muestro necesito listar solo algunos valores por ejemplo si Oferta_Prod = 0
pero resulta que me esta listando todos los valores
no se como lo puedo hacer
si me pueden ayudar mucha gracias
  #2 (permalink)  
Antiguo 08/11/2007, 06:48
Avatar de Kelpie  
Fecha de Ingreso: febrero-2002
Ubicación: NorthSpain
Mensajes: 609
Antigüedad: 23 años, 2 meses
Puntos: 8
Re: ultima duda

No le has dado valor a la variable Oferta_prod, por lo que siempre será "cero"... Supongo que lo que uqieres es mostrar solo los registros que tengan 0 en Oferta_prod (el campo rs(2)). Tienes dos opciones:

La primera es filtrar al recorrer el Recordset, que es la que empleas, pero empleando rs(2)
...
do while not Rs.eof
if(Rs(2)=0) then
...

La segunda es sacar solo esos valores de la base, modificando la consulta, y entonces te sobraría el if:

SQL="SELECT ID_Prod, Tipo_Prod, Oferta_Prod, Marca_prod, Precio_prod FROM Tabla WHERE Oferta_Prod=0"
__________________
Kelpie
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 09:58.