AJAX paging (content involves stored procedures)
<1>
First, we declare and define the stored procedure in the database (SQL Server ).
Use salesif (exists (select * from sys. objects where name = 'proc _ location_Paging ') drop proc proc_location_Paginggocreate proc proc_location_Paging -- create a stored procedure (@ pageSize int, -- page size @ currentpage int, -- current page @ rowCount int output, -- total number of rows (outgoing parameter) @ pageCount int output -- total number of pages (outgoing parameter) asbeginselect @ rowCount = COUNT (locid) from location -- assign a value to @ rowCount: select @ pageCount = CEILING (count (locid) + 0.0)/@ pageSize) from location -- Assign a value to @ pageCount: select top (@ pagesize) * from (select ROW_NUMBER () over (order by locid) as rowID, * from location) as t1where rowID> (@ pageSize * (@ currentpage-1) endgo ----------------------------------- the above indicates that the stored procedure has been defined. --------------------------------- The following describes how to execute this stored procedure. We can see that the results declare @ rowCount int, @ pageCount int -- declare two parameters first -- execute the proc_location_Paging stored procedure. @ RowCount, @ pageCount is followed by output, which indicates that both of them are output parameters exec proc_location_Paging 10, 1, @ rowCount output, @ pageCount output select @ rowCount, @ pageCount -- query the values of these two parameters