Recommended: Methods for parsing various types of data files in ASP 1. Create an MdbRecordset object. An MDB database is a complete database that may contain several data tables. In this function, the function of Connection is to connect to the database, and the function of Recordset is to open the data table. Function CreateMdbRecordset (database file name, data table name or select statement) Dim conn,Provider,DBPat
Display format:
ID NAME | ID NAME
1 JULIET | 2 PALYBOY
3 BABY |4 TOM
5 LENA | 6 JERY
Number of pages before and after pages: 1/4 6 items/Total number of records on pages: 25 items
Code:
<!--#include file=conn.asp--> <html> <body bgcolor=#FFFFF text=#000000> <table width=60% border=1 align=center> <% dim rs dim sql msg_per_page = 4 'Define the number of records displayed per page set rs = server.createobject(adodb.recordset) sql = select * from page order by id 'Change it into your own SQL statement rs.cursorlocation = 3 'Using client cursors can improve efficiency rs.pagesize = msg_per_page 'Define the page record set display number of records per page rs.open sql,conn,0,1 if err.number<>0 then 'Error handling response.write database operation failed: & err.description err.clear else if not (rs.eof and rs.bof) then 'Detection whether the record set is empty totalrec = RS.RecordCount 'totalrec: Total number of records if rs.recordcount mod msg_per_page = 0 then 'Calculate the total number of pages, recordcount: the total number of records of data n = rs.recordcount/msg_per_page 'n:Total number of pages else n = rs.recordcount/msg_per_page+1 end if currentpage = request(page) 'currentpage: Current page If currentpage <> then currentpage = cint(currentpage) if currentpage < 1 then currentpage = 1 end if if err.number <> 0 then err.clear currentpage = 1 end if else currentpage = 1 End if if currentpage*msg_per_page > totalrec and not((currentpage-1)*msg_per_page < totalrec)then currentPage=1 end if rs.absolutepage = currentpage 'absolutepage: Set the pointer to the beginning of a page rowcount = rs.pagesize 'pagesize: Set the number of data records for each page dim i dim k %> <tr align=center valign=middle> <td width=25%>ID1</td> <td width=25%>name1</td> <td width=25%>ID2</td> <td width=25%>name2</td> </tr> <%do while not rs.eof and rowcount > 0%> <tr align=center valign=middle> <td width=25%><%=rs(id)%></td> <td width=25%><%=rs(testname)%></td> <td> <% rowcount=rowcount-1 rs.MoveNext if not rs.EOF then %> <%=rs(id)%> </td> <td width=25%><%=rs(testname)%></td> </tr> <% rowcount=rowcount-1 rs.MoveNext else Response.Write </td><td> </td></tr> end if loop end if end if rs.close set rs=nothing %> </table> |
Share: parse the syntax parameters of the DateDiff function Description returns the time interval between two dates. Syntax DateDiff(interval, date1, date2 [,firstdayofweek][, firstweekofyear]]) The syntax of the DateDiff function has the following parameters: Parameter description interval Required. String expression represents the time interval used to calculate date1 and date2. Related values
2 pages in total Previous page 12 Next page