Ver Mensaje Individual
  #5 (permalink)  
Antiguo 26/03/2005, 05:34
sqa212
 
Fecha de Ingreso: mayo-2003
Mensajes: 866
Antigüedad: 22 años
Puntos: 0
He suprimido codigo relacionado con la presentacion, para que se vea mas claro.
He creado la funcion numeroHM para intentar ver la suma de hombres y mujeres hasta el registro actual,
por una parte falla en algo porque en el primer registro de cada pagina no me muestra nada, y
por otra parte no creo que esta sea la forma correcta de hacer lo que quiero, porque hace mucho uso
de los recursos, ya que realiza una nueva consulta para cada registro.
¿Por que no me muestra el primer registro?
¿Alguna otra forma mas eficiente?
<%
function numeroHM(idsocio)

dim sql, rs

TotalH= 0
TotalM= 0

sql = "select sum (BalanceH) as TotalH,sum (BalanceM) as TotalM from reproductores where idsocio<=" & idsocio
set rs = Db.Execute(sql)
if not (rs.BOF and rs.EOF) then
TotalH = rs.Fields("TotalH").Value
TotalM = rs.Fields("TotalM").Value
end if
rs.close
set rs=Nothing
end function
%>

<%
DIM mySQL, objRS
mySQL = "SELECT * FROM socios ORDER BY idsocio ASC"
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.CursorType = 1
objRS.Open mySQL, db

DIM intPageRecords, intRecords, intRecordCount, intCurrentPage
DIM intNumberOfPages, intDisplayPage
intPageRecords = Request.Querystring("pagina")
IF intPageRecords = "" THEN intPageRecords = 1 : intRecords = 1
intRecords = intPageRecords
intPageRecords = ((intPageRecords - 1) * 25) +1
intRecordCount = 0
IF NOT objRS.EOF THEN
objRS.Move (intPageRecords - 1)
DO WHILE intRecordCount < 25 and NOT objRS.EOF
%>
<%=objRS("balanceM") %>
<%=objRS("balanceH") %>
<%idsocio=objRS("idsocio") %>
<%=numeroHM(idsocio)%>
<%=TotalM%>
<%=TotalH%>

<%
objRS.MoveNext
intRecordCount = intRecordCount +1
Loop
END IF
%>

<%
intCurrentPage = Request.Querystring("pagina")
IF intCurrentPage = "" THEN intCurrentPage = 1
intNumberOfPages = int(objRS.RecordCount \ 25)
IF objRS.RecordCount MOD 25<> 0 THEN intNumberOfPages = intNumberOfPages + 1
Response.Write("Página: [")
FOR intDisplayPage = 1 TO intNumberOfPages
IF Cint(intDisplayPage) = Cint(intCurrentPage) THEN
Response.Write " <b>" & intDisplayPage & "</b> "
ELSE
Response.Write " <a href=""liSTSUM.asp?pagina=" & intDisplayPage & """>" & intDisplayPage &_
"</a> "
END IF
NEXT
Response.Write ("]")
%>
</body>
</html>
<%
db.close
set db=nothing
%>