<%SetMy=NewPageWithMy.SetConnstr=Connstr'數(shù)據(jù)庫鏈接字符串.SetStrTable="users"'表名.SetStrText="id,username,type,names"'查詢的字段.SetStrIndex="id"'主鍵rsArray=.G" />

欧美三区_成人在线免费观看视频_欧美极品少妇xxxxⅹ免费视频_a级毛片免费播放_鲁一鲁中文字幕久久_亚洲一级特黄

asp分頁存儲過程

系統(tǒng) 1891 0
最簡單使用方法(適用于任何數(shù)據(jù)表):
test.asp
<!-- #include?file="conn.asp" -->
<!-- #include?file="Page.asp" -->
<%
?
Set ?My? = ? New ?Page
?
With ?My
?.SetConnstr
= Connstr? ' 數(shù)據(jù)庫鏈接字符串
?.SetStrTable = " users " ? ' 表名
?.SetStrText = " id,username,type,names " ? ' 查詢的字段
?.SetStrIndex = " id " ? ' 主鍵
?rsArray = .GetRs()? ' 返回數(shù)據(jù),類型為數(shù)組
? End ? With
%>
< table >
<%
if ? IsArray (rsArray)? then
?
For ?i? = ? 0 ? To ? UBound (rsArray,? 2 )
%>
?
< tr >
?
< td > <% = ?rsArray( 0 ,?i)? %> </ td >
?
< td > <% = ?rsArray( 1 ,?i)? %> </ td >
?
< td > <% = ?rsArray( 2 ,?i)? %> </ td >
?
</ tr >
<%
?
next
end ? if
%>
?
< tr >
?
< td? colspan ="4" > <% = ?My.GetTotalNum? %> 條?每頁 <% = ?My.GetiPageSize? %> 條?共 <% = ?My.GetTotalPage? %> 頁?頁碼: <% = ?My.GetFenYeJmp( false )? %> </ td >
?
</ tr >

</ table >

?

?

還有很多功能可以拓展,復(fù)雜的查詢、排序等,不一一演示了這個是使用到的asp類->Page.asp

?

'*******************************************************
'Page?分頁類
'特點(diǎn):采用?not?in?分頁輸出方法,需配合?sp_Page?存儲過程使用,速度比較快
'輸入?yún)?shù)?connstr:數(shù)據(jù)庫鏈接字符串?StrTable:要查詢的表?StrText:要查詢的字段?StrIndex:索引字段
'可選參數(shù):(iPageSize:每頁記錄數(shù)量?StrWhere:條件語句?StrOrder:排序字段?StrSc:排序方法?ActionStr:From提交的查詢參數(shù))
'輸出參數(shù)?rsArray:返回的記錄集數(shù)組?GetTotalNum:返回的總記錄數(shù)?GetiPage:當(dāng)前頁碼?GetTotalPage:總頁數(shù)?GetiPageSize:每頁顯示條數(shù)
'輸出方法?GetFenYe():分頁?GetFenYeJmp(inForm):帶跳轉(zhuǎn)的分頁
'作者:六月雨?QQ:44569457?整理時間:2008年9月27日
'*******************************************************
Class?Page
?Private?connstr?'數(shù)據(jù)庫鏈接字符串
?
?Private?iPage?'當(dāng)前頁碼
?Private?iPageSize?'每頁記錄數(shù)量
?Private?StrTable?'要查詢的表
?Private?StrText?'要查詢的字段
?Private?StrWhere?'條件語句
?Private?StrIndex?'索引字段
?Private?StrOrder?'排序字段
?Private?StrSc?'排序方法
?
?Private?ActionStr?'翻頁鏈接字符
?Private?Rs_dbs?'記錄集名稱
?Private?cmd?'cmd對象名稱
?Private?rsArray?'返回的記錄集數(shù)組
?Private?TotalNum?'返回的總記錄數(shù)
?
?Private?Sub?Class_Initialize()?'初始化類
?iPageSize=10
?iPage=trim(Request("iPage"))
?ActionStr=""
?StrWhere=""
?StrOrder=""
?StrSc=""
?If?(not?IsNumeric(iPage))?Then
?iPage=1
?Else
?If?iPage
< 1? then?iPage =1
?
If?iPage > 5000000?then?iPage=1
?End?If
?End?Sub
?
?Private?Sub?Class_Terminate()?'釋放類
?set?Rs_dbs=nothing
?End?Sub
?
?Public?Property?Let?SetConnstr(svalue)?'取得:數(shù)據(jù)庫鏈接字符串
?connstr=Lcase(svalue)
?End?Property
?
?Public?Property?Let?SetiPageSize(svalue)?'取得:每頁記錄數(shù)量
?iPageSize=clng(svalue)
?End?Property
?
?Public?Property?Let?SetStrTable(svalue)?'取得:SQL表名
?StrTable=Lcase(svalue)
?End?Property
?
?Public?Property?Let?SetStrText(svalue)?'取得:SQL查詢的字段
?StrText=Lcase(svalue)
?End?Property
?
?Public?Property?Let?SetStrWhere(svalue)?'取得:SQL條件字段
?StrWhere=Lcase(svalue)
?End?Property
?
?Public?Property?Let?SetStrIndex(svalue)?'取得:索引字段
?StrIndex=Lcase(svalue)
?End?Property
?
?Public?Property?Let?SetStrOrder(svalue)?'取得:排序字段
?StrOrder=Lcase(svalue)
?End?Property
?
?Public?Property?Let?SetStrSc(svalue)?'取得:排序方法
?StrSc=Lcase(svalue)
?End?Property
?
?Public?Property?Let?SetActionStr(svalue)?'取得:翻頁鏈接字符
?ActionStr=Lcase(svalue)
?End?Property
?
?Private?Function?MadeOrderBy()?'方法:組合Order?By?語句
?dim?TempStrOrder,TempStrSc,t
?if?StrOrder
<> ""?and?StrSc <> ""?then
?TempStrOrder=split(StrOrder,",")
?TempStrSc=split(StrSc,",")
?if?ubound(TempStrOrder)=ubound(TempStrSc)?then
?for?t=0?to?ubound(TempStrOrder)
?if?t=0?then
?MadeOrderBy=TempStrOrder(t)&"?"
&TempStrSc (t)
?else
?MadeOrderBy=MadeOrderBy&","
&TempStrOrder (t)&"?" &TempStrSc (t)
?end?if
?next
?end?if
?end?if
?End?Function
?
?Private?Sub?OpenRs()?'方法:獲得記錄集
?Set?Rs_dbs=Server.CreateObject("ADODB.RECORDSET")
?Set?cmd?=?Server.CreateObject("ADODB.Command")
?with?cmd
?.ActiveConnection?=?connstr?'數(shù)據(jù)庫連接字串
?.CommandText?=?"sp_Page"?'指定存儲過程名
?.CommandType?=?4?'表明這是一個存儲過程
?.Prepared?=?true?'要求將SQL命令先行編譯
?.Parameters.append?.CreateParameter("@iPage",3,1,4,iPage)?'指定頁數(shù)
?.Parameters.append?.CreateParameter("@iPageSize",3,1,4,iPageSize)?'每頁記錄數(shù)
?.Parameters.append?.CreateParameter("@StrTable",200,1,200,StrTable)?'分頁時要查詢的表名
?.Parameters.append?.CreateParameter("@StrText",200,1,1000,StrText)?'字段
?.Parameters.append?.CreateParameter("@StrWhere",200,1,1000,StrWhere)?'查詢條件where?中的條件語句
?.Parameters.append?.CreateParameter("@StrIndex",200,1,30,StrIndex)?'索引值
?.Parameters.append?.CreateParameter("@StrOrder",200,1,100,MadeOrderBy())?'排序的字段
?.Parameters.Append?.CreateParameter("@StrTotals",3,2,10)?'總頁數(shù)output
?Set?Rs_dbs?=?.Execute
?end?with
?End?Sub
?
?Public?Property?Get?GetRs()?'輸出:記錄集(數(shù)組方式)
?call?OpenRs()
?If?not?(Rs_dbs.eof?and?Rs_dbs.bof?)?then
?GetRs?=?Rs_dbs.GetRows()
?End?If
?Rs_dbs.close
?TotalNum?=?cmd(7)
?set?cmd?=?nothing
?End?Property
?
?Public?Property?Get?GetTotalNum?'輸出:總記錄數(shù)
?GetTotalNum=TotalNum
?End?Property
?
?Public?Property?Get?GetTotalPage?'輸出:總頁數(shù)
?If?(TotalNum?mod?iPageSize)
<> 0?Then
?GetTotalPage=(TotalNum\iPageSize)+1
?Else
?GetTotalPage=(TotalNum\iPageSize)
?End?If
?End?Property
?
?Public?Property?Get?GetiPageSize?'輸出:每頁顯示條數(shù)
?GetiPageSize=iPageSize
?End?Property
?
?Public?Property?Get?GetiPage?'輸出:當(dāng)前頁碼
?GetiPage=iPage
?End?Property
?
?Private?Function?GetQueryUrl()?'方法:獲得當(dāng)前URL
?dim?UrlFile,Query,Querys,i
?UrlFile=?Request.Servervariables("URL")
?Query=?Request.Servervariables("QUERY_STRING")
?Querys=split(Query,"&")
?For?i=0?to?ubound(Querys)
?if?trim(Querys(i))
<> ""?then
?If?trim(Querys(i))=replace(trim(Querys(i)),"iPage=","")?then
?GetQueryUrl=GetQueryUrl
&Querys (i)&"&"
?End?If
?End?If
?Next
?if?ActionStr=""?then
?GetQueryUrl=UrlFile&"?"
&GetQueryUrl
?else
?GetQueryUrl=UrlFile&"?"
&ActionStr &"&" &GetQueryUrl
?end?if
?End?Function
?
?Public?Property?Get?GetFenYe()?'輸出:分頁
?If?(iPage>=1)?and?(clng(iPage)
< =clng (GetTotalPage))?then
?dim?x,y,m,n,i,ActionUrL
?ActionUrL
=GetQueryUrl()
?
If?iPage ="" ?then?iPage =1
?
iPage =Clng(iPage)
?
If?TotalNum< > 0?then
?x=TotalNum\iPageSize
?y=TotalNum?mod?iPageSize
?
?If?y
<> 0?then?x=x+1?'總頁數(shù)
?if?iPage>5?then
?If?(iPage+5)
< =x? then
?n
=iPage-4
?
m =iPage+5
?
Else
?n
=iPage-4
?
m =x
?
End?If
?Else
?n
=1
?
m =10
?
End?If
?
?If?x<
=10? then
?If?x<
> 1?then
?if?iPage
<> 1?then
?Response.Write"?
< a? href ="&ActionUrL&" iPage ="&(iPage-1)&" > 上一頁 </ a > ?"
?end?if
?for?i=1?to?x
?if?iPage=i?then
?Response.Write(i)
?Else
?Response.Write"?
< a? href ="&ActionUrL&" iPage ="&i&" > [" &i &"] </ a > ?"
?End?If
?next
?if?iPage
<> x?then
?Response.Write"?
< a? href ="&ActionUrL&" iPage ="&(iPage+1)&" > 下一頁 </ a > ?"
?end?if
?End?If
?Else
?If?iPage>5?then
?Response.Write"?
< a? href ="&ActionUrL&" iPage =1 > [首頁] </ a > ?"
?End?If
?If?iPage
<> 1?then
?Response.Write"?
< a? href ="&ActionUrL&" iPage ="&(iPage-1)&" > 上一頁 </ a > ?"
?end?if
?for?i=n?to?m
?if?iPage>x?then?Exit?For
?if?iPage=i?then
?Response.Write(i)
?Else
?Response.Write"?
< a? href ="&ActionUrL&" iPage ="&i&" > [" &i &"] </ a > ?"
?End?If
?next
?if?iPage
<> x?then
?Response.Write"?
< a? href ="&ActionUrL&" iPage ="&(iPage+1)&" > 下一頁 </ a > ?"
?End?If
?if?(iPage+5)
< x? then
?Response.Write"?<a?href
="&ActionUrL&" iPage ="&x&" > [尾頁] </ a > ?"
?End?If
?End?If
?End?If
?End?If
?End?Property
?
?Public?Property?Get?GetFenYeJmp(inForm)?'輸出:帶跳轉(zhuǎn)的分頁
?if?inForm?then
?response.Write(GetFenYe()&"?
< input? name ='iPage'? type ='text'? value ="&iPage&" ?id ='iPage'? size ='3' > ?")
?response.Write("
< input? type ='submit'? name ='Submit'? value ='轉(zhuǎn)' > ")
?else
?response.Write("
< form? name ='Jmp'? method ='post'? action ="&GetQueryUrl()&" > ")
?response.Write(GetFenYe()&"?
< input? name ='iPage'? type ='text'? value ="&iPage&" ?id ='iPage'? size ='3' > ")
?response.Write("
< input? type ='submit'? name ='Submit'? value ='轉(zhuǎn)' > ")
?response.Write("
</ form > ")
?end?if
?End?Property
End?Class

?

?存儲過程

?

CREATE ? PROCEDURE ? [ dbo ] . [ sp_Page ]
@iPage ? int = 1 ,? -- 當(dāng)前頁碼
@iPageSize ? int = 10 , -- 每頁條數(shù)
@StrTable ? varchar ( 200 ), -- 查詢的表
@StrText ? varchar ( 1000 ), -- 查詢的字段
@StrWhere ? varchar ( 1000 ), -- 條件
@StrIndex ? varchar ( 30 ), -- 索引
@StrOrder ? varchar ( 100 ) = '' , -- 排序字段
@StrTotals ? int ?output? -- 返回總條數(shù)
? AS

-- 定義變量
declare ? @SqlCount ? nvarchar ( 2000 )
declare ? @Sql ? nvarchar ( 2000 )
declare ? @TempOrder ? nvarchar ( 1000 )

if ? @StrOrder <> ""
?
begin
?
set ? @TempOrder = ' ?order?by? ' + @StrOrder
?
end
else
?
begin
?
set ? @TempOrder = ''
?
end

-- 組合sql語句
if ? @iPage = 1
?
begin
?
set ? @Sql = ' select?top? ' + str ( @iPageSize ) + ' ? ' + @StrText + ' ?from? ' + @StrTable + ' ?where?1=1? ' + @StrWhere + @TempOrder
?
end
else
?
begin
?
set ? @Sql = ' select?top? ' + str ( @iPageSize ) + ' ? ' + @StrText + ' ?from? ' + @StrTable + ' ?where? ' + @StrIndex + ' ?not?in?(select?top? ' + str ( @iPageSize * ( @iPage - 1 )) + ' ? ' + @StrIndex + ' ?from? ' + @StrTable + ' ?where?1=1? ' + @StrWhere + @TempOrder + ' )? ' + @StrWhere + @TempOrder
?
end

set ? @SqlCount = ' select?@StrTotals=isnull(count(*),10000)?from? ' + @StrTable + ' ?where?1=1? ' + @StrWhere

-- 查詢總記錄數(shù)量
exec ?sp_executesql? @SqlCount ,N ' @StrTotals?int?output ' , @StrTotals ?output

-- 執(zhí)行sql語句返回
exec ?( @Sql )
GO

asp分頁存儲過程


更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯(lián)系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點(diǎn)擊下面給點(diǎn)支持吧,站長非常感激您!手機(jī)微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點(diǎn)擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發(fā)表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 色偷偷免费 | 亚洲特黄| 看中国毛片| 欧美经典剧情系列h版在线观看 | 久久成人国产 | 中文字幕精品一区二区三区精品 | 久久精品中文字幕 | 亚洲第一男人天堂 | 国内福利视频 | 欧美精品国产第一区二区 | 天天干天天操天天舔 | 奇米影视在线观看 | 不卡中文一二三区 | 欧美亚洲精品在线 | 久久久精品免费热线观看 | 亚洲午夜在线视频 | 欧美亚洲 尤物久久 综合精品 | 欧美一区二区三区精品国产 | 黄色草逼视频 | 欧美高清在线视频一区二区 | 日韩视频一区二区三区 | 国产精品国产成人国产三级 | 在线观看毛片视频 | 国产图片区 | 欧美伊人久久综合网 | 精品视频免费观看 | 日本久久高清视频 | 久久久人成影片一区二区三区 | 精品久久精品 | 香蕉在线影院 | 五月综合久久 | 亚洲日韩中文字幕 | 亚洲午夜成激人情在线影院 | 成人欧美在线观看 | 91精品国产综合久久福利软件 | 日本一区免费 | 91在线一区二区三区 | a视频免费 | 99热久久这里只精品国产9 | 亚洲欧美在线观看视频 | 免费的黄网站男人的天堂 |