ASP从数据库直接输出json 以,区分多行在最后一行去掉,
([<%
dim conn,connstr,rs,sql
set conn = Server.CreateObject("Adodb.Connection")
connstr = "Provider=SQLOLEDB;data source=127.0.0.1;initial catalog=数据库;uid=数据库用户;pwd=数据库密码"
conn.open connstr
set rs = Server.CreateObject("Adodb.RecordSet")
sql = "select Name,userid from user"
rs.open sql,conn,1,1
While Not rs.EOF
Name = rs("Name")
userid = rs("userid")
response.write "{""Name"":"""&Name&""",""userid"":"&userid&"}"
if not rs.eof Then
Response.Write ","
end if
rs.MoveNext
Wend
rs.close
conn.close
set conn=nothing
%>])
怎么都是一直多加一个,号
输出的结果为:([{"Name":"用户","userid":1},{"Name":"用户","userid":1}])
想要的输出结果([{"Name":"用户","userid":1},{"Name":"用户","userid":1}])