asp預存程序分頁函數

來源:互聯網
上載者:User

'=============
'函數:分頁儲存過程
'功能:分頁並編譯
'參數:儲存過程參數
'==============
function page_dbstorce(rs,table,outField,indexfield,pagesize,pageIndex,isRecount,typeOrder,condition)
 set cmd = server.CreateObject("ADODB.Command")
 cmd.CommandText="p_Agents_page_test"
 cmd.CommandType=4
 cmd.prepared = true
 set cmd.ActiveConnection = conn
 cmd.parameters("@tblName") = table
 cmd.parameters("@talFldName") = outField
 cmd.parameters("@fldName")=indexfield
 cmd.parameters("@PageSize")=pagesize
 cmd.parameters("@PageIndex")=pageindex
 cmd.parameters("@IsReCount")=0
 cmd.parameters("@OrderType")=typeOrder
 cmd.parameters("@strWhere")=condition
 set rs = cmd.execute
 if isRecount=1 then
 cmd.parameters("@IsReCount")=1
  cmd.execute
  allRecord = cmd.parameters("@allcount")
 end if
 set cmd = nothing
end function
function getSingalFieldValue(table,fieldstr,condition)
 on error resume next
 dim result
 result = conn.execute("select "&fieldstr&" from "&table&" where "&condition&"")(0)
 if err then result = false
 getSingalFieldValue = result
end function
function errpage(errorstr)
 response.Redirect("/error.asp?ps="&errorstr)
end function


'===========
'儲存過程分頁顯示頁面代碼
'
'===========
function page_catalog(allrecord,allpage,currentpage, tagNum,querystringStr,pagetype)
 dim result,tag,linkstr
 linkstr = ""
 'querystringStr = "&fid="&request.QueryString("fid")&"&sid="&request.QueryString("sid")
 tag = tagNum
  result = "共有<font color=red>"&Allrecord&"</font>個記錄&nbsp;&nbsp;共<font color=red>"&allpage&"</font>頁&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
  if currentpage>1 then
   result = result&"<a href='?page=1"&querystringStr&"'>首頁</a>&nbsp;&nbsp;&nbsp;"
  else
   result = result&"首頁&nbsp;&nbsp;&nbsp;"
  end if
  if currentpage>1 then
   result = result&"<a href='?page="&page-1&querystringStr&"'>上一頁</a>&nbsp;&nbsp;&nbsp;"
  else
   result = result&"上一頁&nbsp;&nbsp;&nbsp;"
  end if
  team=(currentpagetag)
  linkstrNum = ""
  if team>0 then linkstrNum = linkstrNum&"<a href=?page="&currentpage-1&querystringStr&"><<</a>"
  if team<=0 then i=1 else i=0
   if (team+1)*tag>=Allpage then endpage=Allpage else endpage=(team+1)*tag
   for e=team*tag+i to endpage
    if e=currentpage then
     linkstrNum = linkstrNum&"&nbsp;<font color=red>"&e&"</font>"
    else
     linkstrNum = linkstrNum&"&nbsp;<a href=?page="&e&querystringStr&">"&e&"</a>"
    end if
   next
   if team<allpagetag then linkstrNum = linkstrNum&"&nbsp;<a href=?page="&currentpage+1&querystringStr&">>></a>"
   linkstr = linkstr&linkstrNum
   result = result&linkstr&"&nbsp;&nbsp;&nbsp;"
  if currentpage<allpage then
   result = result&"<a href='?page="&page+1&querystringStr&"'>下一頁</a>&nbsp;&nbsp;&nbsp;"
  else
   result = result&"下一頁&nbsp;&nbsp;&nbsp;"
  end if
  if currentpage>=allpage then
   result = result&"尾頁"
  else
   result=result&"<a href='?page="&allpage&querystringStr&"'>尾頁</a>"
  end if
 select case cint(pagetype)
  case 1
   result = linkstrNum
 end select
  page_catalog =result
end function

'分頁儲存過程代碼2
function page_catalog_2(allrecord,allpage,currentpage, tagNum, pagetype)
 dim result,tag,linkstr
 linkstr = ""
 'querystringStr = "&fid="&request.QueryString("fid")&"&sid="&request.QueryString("sid")
 tag = tagNum
  result = "共有<font color=red>"&Allrecord&"</font>個記錄&nbsp;&nbsp;共<font color=red>"&allpage&"</font>頁&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
  if currentpage>1 then
   result = result&"<a href='javascript:changepage(1)'>首頁</a>&nbsp;&nbsp;&nbsp;"
  else
   result = result&"首頁&nbsp;&nbsp;&nbsp;"
  end if
  if currentpage>1 then
   result = result&"<a href='javascript:changepage("&page-1&")'>上一頁</a>&nbsp;&nbsp;&nbsp;"
  else
   result = result&"上一頁&nbsp;&nbsp;&nbsp;"
  end if
  team=(currentpagetag)
  linkstrNum = ""
  if team>0 then linkstrNum = linkstrNum&"<a href='javascript:changepage("&currentpage-1&")'><<</a>"
  if team<=0 then i=1 else i=0
   if (team+1)*tag>=Allpage then endpage=Allpage else endpage=(team+1)*tag
   for e=team*tag+i to endpage
    if e=currentpage then
     linkstrNum = linkstrNum&"&nbsp;<font color=red>"&e&"</font>"
    else
     linkstrNum = linkstrNum&"&nbsp;<a href='javascript:changepage("&e&")'>"&e&"</a>"
    end if
   next
   if team<allpagetag then linkstrNum = linkstrNum&"&nbsp;<a href='javascript:changepage("&currentpage+1&")'>>></a>"
   linkstr = linkstr&linkstrNum
   result = result&linkstr&"&nbsp;&nbsp;&nbsp;"
  if currentpage<allpage then
   result = result&"<a href='javascript:changepage("&page+1&")'>下一頁</a>&nbsp;&nbsp;&nbsp;"
  else
   result = result&"下一頁&nbsp;&nbsp;&nbsp;"
  end if
  if currentpage>=allpage then
   result = result&"尾頁"
  else
   result=result&"<a href='?page="&allpage&querystringStr&"'>尾頁</a>"
  end if
 select case cint(pagetype)
  case 1
   result = linkstrNum
 end select
  page_catalog_2 =result
end function

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.