asp实现读取数据库输出json代码
来源:互联网 发布:最新网络对唱歌曲大全 编辑:程序博客网 时间:2024/05/16 18:07
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
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
0 0
- asp实现读取数据库输出json代码
- asp.net中读取数据库数据代码
- asp 读取 json 列表
- asp.net输出json
- ASP中从数据库读取二进制文件数据代码
- ASP读取、添加、修改、删除数据库的代码
- 用ASP代码实现图片写入数据库
- asp读取数据库教程
- asp读取access数据库
- 关于Java语言的eclipse读取数据库,并将数据转换成JSON格式输出
- asp.net 读取并修改config文件实现代码
- asp.net 读取并显示excel数据的实现代码
- ASP.NET实现从数据库中读取图片的方法
- ASP.NET实现从数据库中读取图片的方法
- ASP.NET实现从数据库中读取图片的方法
- ASP.NET 中实现 读取数据库二进制word并下载
- 实现ASP.NET数据库图片上传与读取的功能
- 数据库数组合并输出json
- oracle数据库中的clob大字段同步到不同库之间的问题解决
- linux 查看文件夹下的文件个数(当前目录的文件数)
- 修改状态栏(StatusBar)图标(icon)(定制自己的状态栏)
- av_interleaved_write_frame 写入H264到mp4中,如果出现B帧,会返回-22 错误
- Android 禁止屏幕休眠和锁屏的方法
- asp实现读取数据库输出json代码
- 配置ImageLoader
- iOS切割字符串,并判断首字母是否为某一个字母
- 视频应用<芒果TV>去除播放广告教程
- 在终端输入多行信息,找出包含“ould”的行,并打印改行
- cvhistgram
- MySQL逻辑备份
- HTML5 Boilerplate with RequireJS
- opencv 3.0 求均值 标准差 mean MeanStdDev