Asp读取SQL记录,转换成JSON,提交给WebService

Junyov Junyov 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
各位好,咨询大家一个问题,Asp查询的Sql值如何转换成JSON格式,提交给WebService,感谢!
<%
dim conn
dim rs
set conn=server.CreateObject("adodb.connection")
set rs=server.CreateObject("adodb.recordset")
conn.Open connstring

sql="select * from Application where ApplyNoID="&request("ApplyNoID")&""
set rs=conn.Execute(sql)
%>

<html>
<head>
<LINK href="../global.css" rel=STYLESHEET type=text/css>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title><%request("ApplyNoID")%></title>
</head>
<script src="../tools/jquery.min.js"></script>
<script language="JavaScript">
function window_onload()
{
window.moveTo(-2,-2);
window.resizeTo(screen.availWidth, screen.availHeight);
}

</script>
<script type="text/javascript">

$(function () {
$("#btn").click(function () {
var jsonObj = {};
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
async: false,
dataType: "json",
url: "http://localhost:8080/Application.asmx/Application1",

data:JSON.stringify({"jsonStr":JSON.stringify(jsonObj)}),
success: function (data) {
alert(data.d);
},
error: function (data) {
alert($.parseJSON(data.responseText).Message);},
});
});

})

</script>
<body bgcolor="#ffffff" onLoad="window_onload()">
<table width="100%" height="30" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="center">
<input type="button" name="" id="btn" value="审核提交" />
</td>
</tr>
</table>
<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="DECFAD">
<tr>
<td width="10%" height=20 align=center bgcolor="DEDFDE">编号</td>
<td width="25%" align=center bgcolor="efefef"><%=rs("no")%></td>
<td width="10%" align=center bgcolor="DEDFDE">名称</td>
<td width="20%" align=center bgcolor="efefef"><%=rs("name")%></td>
</tr>
</table>

<%
dim connorderline
dim rsorderline
set connorderline=server.CreateObject("adodb.connection")
set rsorderline=server.CreateObject("adodb.recordset")
connorderline.Open connstring
rsorderline.Open "select * from Applicationline where ApplyNoID="&request("ApplyNoID"),connorderline,1,1
%>
<br>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><strong><font size="2"><b><font class="title">项目明细</font></b></font></strong></td>
</tr>
<tr>
<td height=2 colspan="2" bgcolor="#4A699C"></td>
</tr>
</table>
<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="DECFAD">
<tr bgcolor="efefef">
<td width="3%" height="15" align=center>序号</td>
<td width="4%" height="15" align=center>型号</td>
<td width="4%" height="15" align=center>数量</td>
</tr>
<%i=1
do while not rsorderline.EOF%>
<tr bgcolor="#FFFFFF">
<td align=center><%=i%></td>
<td align=center><%=rsorderline("model")%></td>
<td align=center><%=rsorderline("qty")%></td>
</tr>
<%
i=i+1
rsorderline.MoveNext
loop

rsorderline.Close
set rsorderline=nothing
connorderline.Close
set connorderline=nothing
%>
</table>
</body>
</html>


...全文

相关推荐

评论 4
收藏 已收藏
分享
返回顶部
Junyov
ASP 28,400 成员 356,938 内容