標籤:
<1>
首先我們在資料庫(SQL Server)中聲明定義預存程序
use salesif(exists(select * from sys.objects where name='proc_location_Paging'))drop proc proc_location_Paginggocreate proc proc_location_Paging --建立預存程序(@pageSize int, --頁大小@currentpage int, --當前頁@rowCount int output, --總行數(傳出參數)@pageCount int output --總頁數(傳出參數))asbeginselect @rowCount= COUNT(locid) from location --給@rowCount賦值select @pageCount= CEILING((count(locid)+0.0)/@pageSize) from location --給@@pageCount賦值select top (@pagesize)* from (select ROW_NUMBER() over(order by locid) as rowID,* from location) as t1where rowID >(@pageSize*(@currentpage-1))endgo---------------------------------以上就表示這個預存程序已經定義完了。---------------------------------以下是執行這個預存程序。我們可以看結果declare @rowCount int,@pageCount int --先聲明兩個參數--執行proc_location_Paging這個預存程序。@rowCount,@pageCount後面都有output 表示它們兩是輸出參數exec proc_location_Paging 10,1,@rowCount output,@pageCount output select @rowCount,@pageCount --查詢這兩個參數的值
AJAX分頁 (內容涉及到 預存程序)