資料顯示函數(asp)

來源:互聯網
上載者:User
函數|資料|顯示 <%
REM -----------------------------------
REM 作 者:王勤軍 qinjunit@yahoo.com
REm 創作日期:2004-10-12
REM 修改日期:2005年1月24日 星期一
REM -----------------------------------


'函數 實用資料分頁顯示函數
'參數:DataSQL ----------- 當前頁面資料的SQL語句
'參數:CountSQL ----------- 查詢總條數的SQL語句
'參數:Page ----------- 哪 頁
'參數:PageSize ----------- 頁 次
'參數:THeadStrings ------- 顯示表頭列名稱定義,用“,”分隔,與DataSQL裡面的列名對應。
'實 例:=======================================
'<!--#include virtual="inc/conn.asp"-->
'<!--#include virtual="inc/RW_DataPager.asp"-->
'<%
'dim iPageSize,CurPage
' iPageSize = 18
' CurPage = 1
'if (Request.Form <> "") then
' if IsEmpty(Request.Form("p")) then
' CurPage = 1
' elseif IsNumeric(Request.Form("p")) then
' CurPage = CLng(Request.Form("p"))
' end if
'end if
'ShowRecords "exec p_show accounts,"&iPageSize&","&CurPage&",'account_code,account_password,account_serial,account_type,account_money,stock_time'","select count(account_code) as total from [accounts]",CLng(CurPage),iPageSize,"卡號,密碼,序號,卡類型,卡金額,入庫時間"

'CloseDB()
'% >
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub ShowRecords(DataSQL,CountSQL,Page,PageSize,ModelStrings,THeadStrings)
dim total,rs,DatMessages
dim UseDataModel
if (Request.Form("pagerTotal") <> "") then
total = CLng(Request.Form("PagerTotal"))
else
total = conn.execute(CountSQL)(0)
end if
if Len(ModelStrings)<8 then '模版長度在此定義為8
UseDataModel = false
else
UseDataModel = true
end if
DatMessages = DatMessages & "<table width=""100%"" border=""0"" align=""center"" cellpadding=""0"" cellspacing=""0"" style=""Border-Collapse:collapse;word-break:break-all"">"
DatMessages = DatMessages & "<form name=""frmPager"" id=""frmPager"" method=""post"">"

if Clng(total) <> 0 then
'set rs = conn.execute(DataSQL)
REM 非預存程序分頁====================
set rs=server.createobject("ADODB.RECORDSET")
rs.Open DataSQL,conn,1,1
rs.PageSize=PageSize
rs.AbsolutePage=Page
REM ==================================

dim thArray,ColCount,k,thStr,i
i = 1 '初始化記數器
ColCount = rs.Fields.Count '擷取總列數

if not UseDataModel then '不使用模版操作
if Len(THeadStrings)<1 then
for k = 0 to (rs.Fields.Count-1)
thStr = thStr & rs.Fields(k).name&","
next
thArray = Split((Mid(thStr,1,len(thStr)-1)),",")
else
thArray = Split(THeadStrings,",")
End if

DatMessages = DatMessages & "<tr bgcolor=""#BFE8FB"">"
for k=0 to (ColCount-1)
DatMessages = DatMessages & "<th class='hyxxtext'>"&thArray(k)&"</th>"
next
DatMessages = DatMessages & "</tr>"
else
DatMessages = DatMessages & "<tr><td>"
end if

'---------資料迴圈開始------------'
while (not rs.eof and i<PageSize)
if not UseDataModel then
if (i mod 2 =0 ) then
DatMessages = DatMessages & "<tr bgcolor=""#E1F4FD"">"
else
DatMessages = DatMessages & "<tr bgcolor=""#FFFFFF"">"
end if

for k=0 to (ColCount-1)
DatMessages = DatMessages & "<td>"&rs(k)&"</td>"
next
DatMessages = DatMessages & "</tr>"
else '批量替換模版資料
Dim OneNoteString
OneNoteString = ModelStrings
for k=0 to (ColCount-1)
if IsNull(rs(k)) then
OneNoteString = Replace(OneNoteString,"{$DATA#"&(k+1)&"}","")
else
OneNoteString = Replace(OneNoteString,"{$DATA#"&(k+1)&"}",HtmlString(rs(k)))



相關文章

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

聯繫我們

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

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