国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > ASP > 正文

asp實現讀取數據庫輸出json代碼

2024-05-04 10:59:30
字體:
來源:轉載
供稿:網友

復制代碼 代碼如下:
Function GetTable(Table,Where,Order,OrderSort,curpage, pagesize,MiniJson)
'Author : nigou
'使用方法 : Response.Write GetTable(Table表名,Where條件,Order主鍵(必須),OrderSort(asc,desc),curpage當前頁, pagesize每頁條數,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

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 噶尔县| 化州市| 大同县| 嵊州市| 建平县| 克山县| 开鲁县| 铁岭县| 邹城市| 淮北市| 宜兰市| 南平市| 墨竹工卡县| 买车| 天镇县| 科尔| 化隆| 大埔区| 丘北县| 洛隆县| 梁平县| 长泰县| 晋州市| 新田县| 台南县| 衢州市| 芦溪县| 大新县| 嘉义县| 和田市| 昆山市| 凤阳县| 富平县| 昌都县| 合江县| 博湖县| 南投市| 博湖县| 杂多县| 阳朔县| 哈巴河县|