---Fichero paginacion.asp
<%@ LANGUAGE="VBScript" %> <% Response.Expires = 0 %> <HTML> <HEAD><TITLE>Ejemplo de paginacion</TITLE></HEAD> <BODY> <% Const adOpenkeyset = 1 SQL="SELECT cur_codigo, cur_nombre FROM cursos " Set DB = Server.CreateObject("ADODB.Connection") DB.Open "DB_nombre", "DB_user", "DB_password" Set RS = Server.CreateObject("ADODB.Recordset") RS.PageSize = 10 RS.Open SQL, DB, adOpenKeyset If RS.EOF AND RS.BOF then %> <CENTER><h3> No hay cursos disponibles</h3></center> <% RS.Close DB.Close Set RS = Nothing Set DB = Nothing Else If Request.QueryString("pagina") = "" Then RS.AbsolutePage = 1 Else RS.AbsolutePage = Request.QueryString("pagina") End If %> <CENTER> Página <% If Request.QueryString("pagina") = "" Then Response.Write(RS.AbsolutePage) Else Response.Write(Request.QueryString("pagina")) End If %> de <% = RS.PageCount %> </CENTER> <CENTER> <TABLE BORDER=0> <TR> <% For p = 1 To RS.PageCount %> <TD ALIGN=CENTER> <FONT SIZE=5 COLOR="red"> <A HREF="paginacion.asp?pagina=<% = p %>"><% = p %></A> </FONT> </TD> <% Next %> </TR> </TABLE> </CENTER> <P> <CENTER> <TABLE BORDER=1> <TR> <TH>Código</TH> <TH>Curso</TH> </TR> <% For i = 1 To RS.PageSize If RS.EOF Then Exit For End If %> <TR> <TD><% = RS("cur_codigo") %></TD> <TD><% = RS("cur_nombre") %></TD> </TR> <% RS.MoveNext Next %> </TABLE> </CENTER> <% RS.Close DB.Close Set RS = Nothing Set DB = Nothing End if %> </BODY> </HTML>
En la línea DB.Open "DB_nombre", "DB_user", "DB_password", evidentemente, hay que sustituir "DB_nombre", "DB_user" y "DB_password" por los valores reales que procedan. Y por supuesto, en la DB tiene que haber una tabla llamada "cursos".