asp實(shí)現(xiàn)讀取數(shù)據(jù)庫輸出json代碼_ASP教程
教程Tag:暫無Tag,歡迎添加,賺取U幣!
推薦:JScript中遍歷Request表單參數(shù)集合的方法JScript下有一個Enumerator對象可以遍歷集合。根據(jù)它的文檔寫了以下程序,可以遍歷整個Request.QueryString集合: 代碼如下: var params = new Enumerator(Request.QueryString); while (!params.atEnd()) { Response.Write(params.item() + : + Request.QueryString(p
代碼如下:
Function GetTable(Table,Where,Order,OrderSort,curpage, pagesize,MiniJson)
'Author : nigou
'使用方法 : Response.Write GetTable(Table表名,Where條件,Order主鍵(必須),OrderSort(asc,desc),curpage當(dāng)前頁, pagesize每頁條數(shù),MiniJson是否輸出為miniUI格式)
'
dim i, j ,rs
if OrderSort="" Then OrderSort="asc"
if Where="" Then Where="asc"
Set Rs=Server.CreateObject("adodb.recordset")
if curpage>1 then
TmpSql="select a.* from ( select top " & (curpage) * pagesize & " * from " & Table & " where " & where & " order by " & Order & " " & OrderSort & ") a left join ( select top " & (curpage-1) * pagesize & " * from " & Table & " where " & where & " order by " & Order & " " & OrderSort & ") b on a." & Order & "=b." & Order & " where iif(b." & Order & ",'0','1')='1'"
else
TmpSql="select a.* from ( select top " & (curpage) * pagesize & " * from " & Table & " where " & where & " order by " & Order & " " & OrderSort & ") a "
end if
if pagesize=0 Then TmpSql = "select * from " & Table
Rs.open TmpSql,conn,1,1
RealSize=Rs.recordcount
for i=0 to Rs.recordcount-1
TmpJson= TmpJson & "{"
for j=0 to Rs.fields.count-1
TmpJson= TmpJson & """" &(Rs.fields(j).name) & """ : "
TmpJson= TmpJson & """" & Rs(j) & """"
if j<Rs.fields.count-1 then TmpJson= TmpJson & " , "
next
TmpJson= TmpJson & " }"
if i<Rs.recordcount-1 then TmpJson= TmpJson & ","
TmpJson= TmpJson & vbcrlf
rs.movenext
next
Rs.close
if MiniJson=1 Then
CountSql="select count("& order &") from " & Table & " where " & where
Rs.open CountSql,Conn,1,1
Counts=Rs(0)
Rs.Close
GetTable=ToMiniUi(TmpJson,Counts)
Else
GetTable=toJson(TmpJson)
end if
Set Rs=nothing
End Function
function toJson(JsonStr)
toJson="[" & vbcrlf & JsonStr & vbcrlf & "]"
end function
Function ToMiniUi(JsonStr,total)
ToMiniUI="{"
ToMiniUI=ToMiniUI & """total"":"" " & total & """," & vbcrlf
ToMiniUI=ToMiniUI & """data"": [" & JsonStr
ToMiniUI=ToMiniUI & "]}"
End Function
PS:最后的參數(shù)是針對miniUI開發(fā)的,可以無視
以上就是本文的全部內(nèi)容了,希望大家能夠喜歡。
分享:如何使用ASP建立虛擬的FTP服務(wù)器ASP中采用組件或無組件上傳技術(shù),均可以實(shí)現(xiàn)文件的上傳功能。由此我們可以采用ASP的無組件上傳技術(shù),在我們自己的站點(diǎn)上建立一個虛擬的FTP服務(wù)器,象真正的FTP服務(wù)器一樣,為多個用戶提供遠(yuǎn)程文件的管理,同時各個用戶只能操作自己的文件。 當(dāng)文件上傳的時候,ASP可以
相關(guān)ASP教程:
- 相關(guān)鏈接:
- 教程說明:
ASP教程-asp實(shí)現(xiàn)讀取數(shù)據(jù)庫輸出json代碼
。