Paginar consulta de varias tablas

19/09/2007 - 03:02 por Erika H. | Informe spam
Hola que tal, los molesto nuevamente porque tengo un problema con una
consulta, tengo un select donde uno varias tablas, debido a que el numero de
registros es grande lo deseo paginar, pero no me esta haciendo esta
operacion, alguien me podria decir si encuentra un error en el codigo?, si le
doy paginar cada 5 o 6 registros no hace nada.
Les mando el codigo:
<%
Response.addHeader "pragma", "no-cache"
Response.CacheControl = "Private"
Response.Expires = 0
Response.buffer=True %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>REMISION-CONFETEX</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#89CBB0">
<!--#include file="funciones.asp" -->
<%
Dim O_Conn
Dim RS
BASE_OPERAR

'Extra tamaño de folio, que indica la numeracion del reporte a mostrar,
elimina espacios en blanco y asigna cadena de "0".
longitud=Len(Trim(session("folio")))
If longitud=1 Then
folioc="000" + session("folio")
ElseIf longitud=2 Then
folioc="00" + session("folio")
ElseIf longitud=3 Then
folioc="0" + session("folio")
End If
%>
<center><table border=1 color="#000000"><td><IMG
src="http://www.confetex.com/intranet/LO....gif" width="73"
height="61" alt="CONFETEX - 3kb" border="0"></td><td><center><b><FONT
face="bernhardfashion bt" size="2">Nota de
Salida</FONT></b></center></td><td><FONT face="bernhardfashion bt"
size="2"><% Response.Write "<b>Folio #:
<u>"&folioc&"</u></b>"%></font></td></table></center>
<%

'Debido a que algunos servidores estan cofigurados en idioma ingles,se toma
la fecha del sistema y se agrupa a la configuracion en español
fecha=Date
dia=Day(fecha)
mes=Month(fecha)
anio=Year(fecha)
fechagenerica=CStr(dia) & "/" & CStr(mes) & "/" & CStr(anio)
'Abrimos la tabla donde se tienen las ordenes a consultar, si es diferente a
cero se muestra la informacion, en caso contraio se envia mensaje de error
RS.Close
Datos="SELECT DISTINCT(od_codigo), od_descrip,or_corte, or_clave, or_piezas,
or_cliente, or_modeloe, or_articulo, or_cliente, c_nombre, lc_telasigna,
cn_cortada,cn_real,cn_planta FROM OrdenD FULL JOIN Orden ON
Orden.or_clave=OrdenD.od_clave FULL OUTER JOIN Temporal ON
Temporal.tm_orden=Orden.or_corte FULL OUTER JOIN Clientes ON
Clientes.c_clave=Orden.or_cliente FULL OUTER JOIN LCortes ON LCortes.lc_orden
= Temporal.tm_orden FULL OUTER JOIN Confeccion ON Confeccion.cn_orden =
LCortes.lc_orden AND Confeccion.cn_clave = LCortes.lc_clave WHERE
Orden.or_corte=Temporal.tm_orden and YEAR(or_fecha)='2007' Order by or_corte"
RS.Open Datos, O_Conn, 3,3, &H0001

'Limitamos a que los registros se muestren 9 registros por pagina
RS.PageSize=6
Pagina= Request.QueryString("Pagina")
If Pagina="" Then Pagina= 1 Else Pagina=CInt(Pagina) %>
<center><table width="635" border="1">
<tr>
<td aling="center" colspan=2><%If Pagina > 1 Then %>
<a href="Nota de Salida_Query.asp?Pagina=<%=Pagina -
1%>"><<Anterior</a>
<%
End If%>
</td>
<td colspan=3><center>P&aacuteg. <%=Pagina%> de
<%=RS.PageCount%></center></td>
<td aling="center" colspan=2>
<%
If Pagina< RS.PageCount Then %>
<a href="Nota de Salida_Query.asp?Pagina=<%=Pagina +
1%>">Siguiente>></a>
<%
End If%>
</td>
</tr>
<tr>
<th width="262" bgcolor="#F8F4C0" colspan=4><div
align="left"><strong><font size="1.8">De:
<input type="text" name="de" size="36"></font></strong></div></th>
<th width="294" bgcolor="#F8F4C0" colspan=3><div
align="left"><strong><font size="1.8">Para:
<input type="text" name="de" size="36"></font></strong></div></th>
<th width="64" bgcolor="#F8F4C0"><div align="center"><strong><font
size="1.5">Fecha:<%=""&fechagenerica&""%></font></strong></div></th>

<%
RS.AbsolutePage=Pagina
Cont=0
aactual=Year(Date)
Datos="SELECT DISTINCT(od_codigo), od_descrip,or_corte, or_clave,
or_piezas, or_cliente, or_modeloe, or_articulo, or_cliente, c_nombre,
lc_telasigna, cn_cortada,cn_real,cn_planta FROM OrdenD FULL JOIN Orden ON
Orden.or_clave=OrdenD.od_clave FULL OUTER JOIN Temporal ON
Temporal.tm_orden=Orden.or_corte FULL OUTER JOIN Clientes ON
Clientes.c_clave=Orden.or_cliente FULL OUTER JOIN LCortes ON LCortes.lc_orden
= Temporal.tm_orden FULL OUTER JOIN Confeccion ON Confeccion.cn_orden =
LCortes.lc_orden AND Confeccion.cn_clave = LCortes.lc_clave WHERE
Orden.or_corte=Temporal.tm_orden and YEAR(or_fecha)='2007' Order by or_corte"
Set RS=O_Conn.execute(Datos)
cantidadc=RS("cn_real")
Do while not RS.eof
Cont=Cont+1
If Cont>RS.PageSize Then Exit Do %>
<tr>
<td width="62" bgcolor="#F8F4C0"><div align="center"><font
size="1.5">Orden</font></div></th>
<td height="16" bgcolor="#E0E0E0" width="46"><font size="1.5"><a
href="http://www.confetex.com/intranet/Co...n=<%=RS("or_corte")%>&clave=<%=RS("or_clave")%>"
target="_blank"><%=RS("or_corte")%></a></font><input type="hidden"
name="p_orden" size="10" value="<%=RS("or_corte")%>"></td>
<th width="66" nowrap bgcolor="#F8F4C0"><div align="center">
<span style="font-weight: 400"><font
size="1.5">Articulo</font></span></div></th>
<td nowrap bgcolor="#E0E0E0"><font
size="1.5"><%=RS("or_articulo")%></font></td>
<th width="64" bgcolor="#F8F4C0"><div align="center">
<span style="font-weight: 400"><font size="1.5">Tipo de
Tela</font></span></div></th>
<td nowrap bgcolor="#E0E0E0" width="122"><font
size="1.5"><%=RS("od_descrip")%></font></td>
<td width="96" bgcolor="#F8F4C0"><div align="center"><font
size="1.5">Código de Tela</font></div></th>
<td nowrap bgcolor="#E0E0E0" width="64"><font
size="1.5"><%=RS("od_codigo")%></font></td>
</tr>
<tr>
<th width="62" bgcolor="#F8F4C0"><align="center">
<span style="font-weight: 400"><font size="1.5">C.
Liquidada</font></span></th>
<td nowrap bgcolor="#E0E0E0" width="46"><font
size="1.5"><%=RS("lc_telasigna")%></font></td>
<th width="66" nowrap bgcolor="#F8F4C0"><div align="center">
<span style="font-weight: 400"><font size="1.5">C.
Enviada</font></span></div></th>
<td width="66" bgcolor="#E0E0E0"><font size="1.5"><input type="text"
value"" name="c_enviada" size="10"></font></td>
<th width="64" bgcolor="#F8F4C0"><div align="center">
<span style="font-weight: 400"><font
size="1.5">Planta</font></span></div></th>
<td nowrap bgcolor="#E0E0E0" width="122"><font
size="1.5"><%=RS("cn_planta")%></font></td>
<th width="96" bgcolor="#F8F4C0"><div align="center">
<span style="font-weight: 400"><font
size="1.5">Cliente</font></span></div></th>
<%
clavec=Trim(RS("or_cliente"))
If clavec01 Then
nombrec="GICSA"
ElseIf clavec03 Then
nombrec="JUNIOR"
ElseIf clavec04 Then
nombrec="ANDREA"
ElseIf clavec="0005" Then
nombrec="CONVERSE"
ElseIf clavec08 Then
nombrec="STYLING"
ElseIf clavec113 Then
nombrec="WESTERN"
ElseIf clavec133 Then
nombrec="MEXIJEANS"
ElseIf clavec="00132" Then
nombrec="LEVIS"
ElseIf clavec="06CTT" Then
nombrec="CONFETEX"
End If
%>
<td nowrap bgcolor="#E0E0E0" width="64"><font
size="1.5"><%=""&nombrec&""%></font></td>
</tr>
<tr>
<th width="114" colspan="2" nowrap bgcolor="#F8F4C0" height="25"><div
align="center">
<span style="font-weight: 400"><font
size="1.5">Descripción</font></span></div></th>
<td width="527" colspan="6" font size="1.5" bgcolor="#E0E0E0"
height="25"><font size="1.5">
<input type="text" value"" name="descrip" size="82"></font></td>
</tr>
<%
RS.MoveNext
Loop
%>
</table>
<table>
<tr><td align="center"><B><FONT face="times new roman" size="2">Gerente
de Planta:</td><td> </td><td align="center"><B><FONT face="times new
roman" size="2.5">Entrego:</td><td> </td><td align="center"><B><FONT
face="times new roman" size="2.5">Recibio:</td></tr>
<tr><td height="23">________________________</td><td
height="23"> </td>
<td height="23">________________________</td><td height="23"> </td>
<td height="23">________________________</td></tr>
<tr><td align="center"><B><FONT face="times new roman" size="2">Nombre y
Firma:</td><td> </td><td align="center"><B><FONT face="times new
roman" size="2.5">Nombre y Firma:</td><td> </td><td
align="center"><B><FONT face="times new roman" size="2.5">Nombre y
Firma:</td></tr>
</table>
<%
RS.Close
O_Conn.Close
Set RS=Nothing
Set O_Conn=Nothing
%>
</body>
</html>

Agradezco de antemano la ayuda
Saludos
Erika Hdez
 

Leer las respuestas

#1 urko binarya
19/09/2007 - 08:52 | Informe spam
unos de los problemas que veo es que ejecutas la consulta dos veces
y el RS.AbsolutePage que tiene es de la consulta anterior
te pongo mas abajo el codigo que utilizo yo para listados, aunque en otros
utilizo el getrows. <%
RS.AbsolutePage=Pagina
Cont=0
aactual=Year(Date)
Datos="SELECT DISTINCT(od_codigo), od_descrip,or_corte, or_clave,
or_piezas, or_cliente, or_modeloe, or_articulo, or_cliente, c_nombre,
lc_telasigna, cn_cortada,cn_real,cn_planta FROM OrdenD FULL JOIN Orden ON
Orden.or_clave=OrdenD.od_clave FULL OUTER JOIN Temporal ON
Temporal.tm_orden=Orden.or_corte FULL OUTER JOIN Clientes ON
Clientes.c_clave=Orden.or_cliente FULL OUTER JOIN LCortes ON
LCortes.lc_orden
= Temporal.tm_orden FULL OUTER JOIN Confeccion ON Confeccion.cn_orden LCortes.lc_orden AND Confeccion.cn_clave = LCortes.lc_clave WHERE
Orden.or_corte=Temporal.tm_orden and YEAR(or_fecha)='2007' Order by
or_corte"
Set RS=O_Conn.execute(Datos)
cantidadc=RS("cn_real")
Do while not RS.eof
Cont=Cont+1
If Cont>RS.PageSize Then Exit Do %>
te pongo lo que suelo hacer yo
<%' BUSQUEDA
set rst=server.CreateObject("ADODB.RecordSet")

consulta="SELECT * FROM configuracionemail order by activo"
rst.open consulta,Base,1,2
%>
<% rst.PageSize = 5%>
<%if request.form("pagina")="" then
pagina=1
else
pagina=request.form("pagina")
end if%>

<%
for resultados = 1 to rst.PageSize
'esto mira si el cliente se ha desconectado y no deje "colgao" un proceso
if not Response.IsClientConnected then
Response.End
end if
if not rst.eof then
id=rst("idconfiguracion")
activo=rst("activo")%>
<tr><td>..</td></tr>

<%
end if
next
%>

saludos
urko



"Erika H." escribió en el mensaje
news:
Hola que tal, los molesto nuevamente porque tengo un problema con una
consulta, tengo un select donde uno varias tablas, debido a que el numero
de
registros es grande lo deseo paginar, pero no me esta haciendo esta
operacion, alguien me podria decir si encuentra un error en el codigo?, si
le
doy paginar cada 5 o 6 registros no hace nada.
Les mando el codigo:
<%
Response.addHeader "pragma", "no-cache"
Response.CacheControl = "Private"
Response.Expires = 0
Response.buffer=True %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>REMISION-CONFETEX</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#89CBB0">
<!--#include file="funciones.asp" -->
<%
Dim O_Conn
Dim RS
BASE_OPERAR

'Extra tamaño de folio, que indica la numeracion del reporte a mostrar,
elimina espacios en blanco y asigna cadena de "0".
longitud=Len(Trim(session("folio")))
If longitud=1 Then
folioc="000" + session("folio")
ElseIf longitud=2 Then
folioc="00" + session("folio")
ElseIf longitud=3 Then
folioc="0" + session("folio")
End If
%>
<center><table border=1 color="#000000"><td><IMG
src="http://www.confetex.com/intranet/LO....gif" width="73"
height="61" alt="CONFETEX - 3kb" border="0"></td><td><center><b><FONT
face="bernhardfashion bt" size="2">Nota de
Salida</FONT></b></center></td><td><FONT face="bernhardfashion bt"
size="2"><% Response.Write "<b>Folio #:
<u>"&folioc&"</u></b>"%></font></td></table></center>
<%

'Debido a que algunos servidores estan cofigurados en idioma ingles,se
toma
la fecha del sistema y se agrupa a la configuracion en español
fecha=Date
dia=Day(fecha)
mes=Month(fecha)
anio=Year(fecha)
fechagenerica=CStr(dia) & "/" & CStr(mes) & "/" & CStr(anio)
'Abrimos la tabla donde se tienen las ordenes a consultar, si es diferente
a
cero se muestra la informacion, en caso contraio se envia mensaje de error
RS.Close
Datos="SELECT DISTINCT(od_codigo), od_descrip,or_corte, or_clave,
or_piezas,
or_cliente, or_modeloe, or_articulo, or_cliente, c_nombre, lc_telasigna,
cn_cortada,cn_real,cn_planta FROM OrdenD FULL JOIN Orden ON
Orden.or_clave=OrdenD.od_clave FULL OUTER JOIN Temporal ON
Temporal.tm_orden=Orden.or_corte FULL OUTER JOIN Clientes ON
Clientes.c_clave=Orden.or_cliente FULL OUTER JOIN LCortes ON
LCortes.lc_orden
= Temporal.tm_orden FULL OUTER JOIN Confeccion ON Confeccion.cn_orden > LCortes.lc_orden AND Confeccion.cn_clave = LCortes.lc_clave WHERE
Orden.or_corte=Temporal.tm_orden and YEAR(or_fecha)='2007' Order by
or_corte"
RS.Open Datos, O_Conn, 3,3, &H0001

'Limitamos a que los registros se muestren 9 registros por pagina
RS.PageSize=6
Pagina= Request.QueryString("Pagina")
If Pagina="" Then Pagina= 1 Else Pagina=CInt(Pagina) %>
<center><table width="635" border="1">
<tr>
<td aling="center" colspan=2><%If Pagina > 1 Then %>
<a href="Nota de Salida_Query.asp?Pagina=<%=Pagina -
1%>"><<Anterior</a>
<%
End If%>
</td>
<td colspan=3><center>P&aacuteg. <%=Pagina%> de
<%=RS.PageCount%></center></td>
<td aling="center" colspan=2>
<%
If Pagina< RS.PageCount Then %>
<a href="Nota de Salida_Query.asp?Pagina=<%=Pagina +
1%>">Siguiente>></a>
<%
End If%>
</td>
</tr>
<tr>
<th width="262" bgcolor="#F8F4C0" colspan=4><div
align="left"><strong><font size="1.8">De:
<input type="text" name="de" size="36"></font></strong></div></th>
<th width="294" bgcolor="#F8F4C0" colspan=3><div
align="left"><strong><font size="1.8">Para:
<input type="text" name="de" size="36"></font></strong></div></th>
<th width="64" bgcolor="#F8F4C0"><div align="center"><strong><font
size="1.5">Fecha:<%=""&fechagenerica&""%></font></strong></div></th>

<%
RS.AbsolutePage=Pagina
Cont=0
aactual=Year(Date)
Datos="SELECT DISTINCT(od_codigo), od_descrip,or_corte, or_clave,
or_piezas, or_cliente, or_modeloe, or_articulo, or_cliente, c_nombre,
lc_telasigna, cn_cortada,cn_real,cn_planta FROM OrdenD FULL JOIN Orden ON
Orden.or_clave=OrdenD.od_clave FULL OUTER JOIN Temporal ON
Temporal.tm_orden=Orden.or_corte FULL OUTER JOIN Clientes ON
Clientes.c_clave=Orden.or_cliente FULL OUTER JOIN LCortes ON
LCortes.lc_orden
= Temporal.tm_orden FULL OUTER JOIN Confeccion ON Confeccion.cn_orden > LCortes.lc_orden AND Confeccion.cn_clave = LCortes.lc_clave WHERE
Orden.or_corte=Temporal.tm_orden and YEAR(or_fecha)='2007' Order by
or_corte"
Set RS=O_Conn.execute(Datos)
cantidadc=RS("cn_real")
Do while not RS.eof
Cont=Cont+1
If Cont>RS.PageSize Then Exit Do %>
<tr>
<td width="62" bgcolor="#F8F4C0"><div align="center"><font
size="1.5">Orden</font></div></th>
<td height="16" bgcolor="#E0E0E0" width="46"><font size="1.5"><a
href="http://www.confetex.com/intranet/Co...n=<%=RS("or_corte")%>&clave=<%=RS("or_clave")%>"
target="_blank"><%=RS("or_corte")%></a></font><input type="hidden"
name="p_orden" size="10" value="<%=RS("or_corte")%>"></td>
<th width="66" nowrap bgcolor="#F8F4C0"><div align="center">
<span style="font-weight: 400"><font
size="1.5">Articulo</font></span></div></th>
<td nowrap bgcolor="#E0E0E0"><font
size="1.5"><%=RS("or_articulo")%></font></td>
<th width="64" bgcolor="#F8F4C0"><div align="center">
<span style="font-weight: 400"><font size="1.5">Tipo de
Tela</font></span></div></th>
<td nowrap bgcolor="#E0E0E0" width="122"><font
size="1.5"><%=RS("od_descrip")%></font></td>
<td width="96" bgcolor="#F8F4C0"><div align="center"><font
size="1.5">Código de Tela</font></div></th>
<td nowrap bgcolor="#E0E0E0" width="64"><font
size="1.5"><%=RS("od_codigo")%></font></td>
</tr>
<tr>
<th width="62" bgcolor="#F8F4C0"><align="center">
<span style="font-weight: 400"><font size="1.5">C.
Liquidada</font></span></th>
<td nowrap bgcolor="#E0E0E0" width="46"><font
size="1.5"><%=RS("lc_telasigna")%></font></td>
<th width="66" nowrap bgcolor="#F8F4C0"><div align="center">
<span style="font-weight: 400"><font size="1.5">C.
Enviada</font></span></div></th>
<td width="66" bgcolor="#E0E0E0"><font size="1.5"><input type="text"
value"" name="c_enviada" size="10"></font></td>
<th width="64" bgcolor="#F8F4C0"><div align="center">
<span style="font-weight: 400"><font
size="1.5">Planta</font></span></div></th>
<td nowrap bgcolor="#E0E0E0" width="122"><font
size="1.5"><%=RS("cn_planta")%></font></td>
<th width="96" bgcolor="#F8F4C0"><div align="center">
<span style="font-weight: 400"><font
size="1.5">Cliente</font></span></div></th>
<%
clavec=Trim(RS("or_cliente"))
If clavec01 Then
nombrec="GICSA"
ElseIf clavec03 Then
nombrec="JUNIOR"
ElseIf clavec04 Then
nombrec="ANDREA"
ElseIf clavec="0005" Then
nombrec="CONVERSE"
ElseIf clavec08 Then
nombrec="STYLING"
ElseIf clavec113 Then
nombrec="WESTERN"
ElseIf clavec133 Then
nombrec="MEXIJEANS"
ElseIf clavec="00132" Then
nombrec="LEVIS"
ElseIf clavec="06CTT" Then
nombrec="CONFETEX"
End If
%>
<td nowrap bgcolor="#E0E0E0" width="64"><font
size="1.5"><%=""&nombrec&""%></font></td>
</tr>
<tr>
<th width="114" colspan="2" nowrap bgcolor="#F8F4C0" height="25"><div
align="center">
<span style="font-weight: 400"><font
size="1.5">Descripción</font></span></div></th>
<td width="527" colspan="6" font size="1.5" bgcolor="#E0E0E0"
height="25"><font size="1.5">
<input type="text" value"" name="descrip" size="82"></font></td>
</tr>
<%
RS.MoveNext
Loop
%>
</table>
<table>
<tr><td align="center"><B><FONT face="times new roman" size="2">Gerente
de Planta:</td><td> </td><td align="center"><B><FONT face="times
new
roman" size="2.5">Entrego:</td><td> </td><td
align="center"><B><FONT
face="times new roman" size="2.5">Recibio:</td></tr>
<tr><td height="23">________________________</td><td
height="23"> </td>
<td height="23">________________________</td><td height="23"> </td>
<td height="23">________________________</td></tr>
<tr><td align="center"><B><FONT face="times new roman" size="2">Nombre y
Firma:</td><td> </td><td align="center"><B><FONT face="times new
roman" size="2.5">Nombre y Firma:</td><td> </td><td
align="center"><B><FONT face="times new roman" size="2.5">Nombre y
Firma:</td></tr>
</table>
<%
RS.Close
O_Conn.Close
Set RS=Nothing
Set O_Conn=Nothing
%>
</body>
</html>

Agradezco de antemano la ayuda
Saludos
Erika Hdez

Preguntas similares