asp将数据库数据转换成JSON格式
来源:互联网 发布:linux 局域网上网设置 编辑:程序博客网 时间:2024/05/17 18:15
asp从数据库中读取数据,以JSON形式输出,作为Android 的WebService
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="conn.asp" -->
<%
response.Charset = "gb2312"
Dim nPageSize,strCatID,strCatName,strInfoView,strInfoFile,nPageCount
strCatID=request("ChannelID")
nPageSize=request("PageSize")
If not Isnumeric(strCatID) Then
strCatID=0
End If
If not Isnumeric(nPageSize) Then
nPageSize=0
End If
If strCatID<=0 Then
Response.Write "参数错误!"
Response.End
End If
If nPageSize<=0 Then
Response.Write "参数错误!"
Response.End
End If
cmdQuery.CommandText = "select top "&nPageSize&" nid,title,source,digest,ptime from t_news where cid='"&strCatID&"' order by nid desc"
Set rstCat=cmdQuery.Execute
If not rstCat.Eof Then
response.Write "{'ret':0,'data':{'newslist':["
for i=1 to nPageSize
response.Write "{"
response.Write "'title':'"&rstCat("title")&"',"
Set cmdQuery2=Server.CreateObject("ADODB.Command")
Set cmdQuery2.ActiveConnection = cnnMyedu123
cmdQuery2.CommandType=1
cmdQuery2.CommandText = "select * from ViewCommentCount where nid="&rstCat("nid")
Set rstCount=cmdQuery2.Execute
if not rstCount.eof then
response.Write "'commentcount':"&rstCount("commentcount")&","
else
response.Write "'commentcount':0,"
end if
set rstCount = nothing
set cmdQuery2 = nothing
response.Write "'source':'"&rstCat("source")&"',"
response.Write "'nid':"&rstCat("nid")&","
response.Write "'digest':'"&rstCat("digest")&"',"
response.Write "'ptime':'"&rstCat("ptime")&"'"
if i = nPageSize-1 then
response.Write "}"
else
response.Write "},"
end if
rstCat.movenext
if rstCat.eof then exit for end if
next
response.Write "],"
response.Write "'totalnum':"&nPageSize&""
response.Write "},"
response.Write "'msg':'ok'"
response.Write "}"
Else
Response.Write "栏目不存在!"
Response.End
End If
Set rstCat=Nothing
set cmdQuery = nothing
%>
- asp将数据库数据转换成JSON格式
- 将数据库中的数据转换成json格式
- 如何将对象转换成json格式,如何将json格式数据转换成js对象
- 关于Java语言的eclipse读取数据库,并将数据转换成JSON格式输出
- php将从数据库中获得的数据转换成json格式并输出
- java将XML文档转换成json格式数据
- 将map型数据转换成json格式的字符串
- 将XML形式的数据转换成Json格式
- 使用Jsonlib将对象转换成json格式数据
- Java将XML转换成Json格式数据
- 将数据转换为json格式代码
- asp将数据库里的记录转换成json
- asp.net 将数据库里的记录转换成json
- Asp.net将数据库里的记录转换成json
- asp将数据库里的记录转换成json
- 数据库中查询出来的数据转换成json格式
- android 将数据转换成JSON数据格式并使用JSONObject解析JSON格式的数据
- php将数据库中的数据转换成xml格式的
- 万恶的Soft Deadlock!
- 无边框窗口
- Windows7自带的Media Player不能正常播放
- Java Observable 模式
- 数据结构与程序设计作业4
- asp将数据库数据转换成JSON格式
- NET 平台下的WebService
- PhoneGap2.X及3.X项目工程创建方法(IOS)
- viewflipper控件ontouch事件和onclick事件问题
- 关于chown: Non-super user cannot change owner
- [IETF] Congestion Exposure
- LDA学习心得
- python 日志模块
- WITH+HInt MATERIALIZE 不见得有效