困惑多日的两表查询余额,为什么在数据库SQL测试成行,但在ASP页面中就不行了呢?
在ASP的页面中,代码这么写htbh=request.form("ht_name")
set rs_1 = server.createobject("adodb.recordset")
sql = "SELECT a.htbh, a.gys, a.htnr, a.htj, Sum(b.fkje) AS fkje_hj, nz(a.htj)-nz(Sum(b.fkje)) AS sqje_hj FROM htsx AS a LEFT JOIN fkmx AS b ON a.htbh=b.htbh GROUP BY a.htbh, a.gys, a.htnr, a.htj HAVING a.htbh='& htbh &'"
rs_1.open sql,conn,1,1
页面输出:
<%=rs_1("htj")%>
<%=rs_1("sqje_hj")%>
但结果没有显示。
在数据库中SQL用这样测试
SELECT a.htbh, a.gys, a.htnr, a.htj, Sum(b.fkje) AS fkje_hj, nz(a.htj)-nz(Sum(b.fkje)) AS sqje_hj
FROM htsx AS a LEFT JOIN fkmx AS b ON a.htbh=b.htbh
GROUP BY a.htbh, a.gys, a.htnr, a.htj
HAVING a.htbh='XM-002'
执行后的结果
查询2
htbh gys htnr htj fkje_hj sqje_hj
XM-002 南宁五洋化工 磷酸 200,000.00 62300 137700
在ASP的页面中,代码改为(a.htbh='& htbh &'改为a.htbh='XM-002')
代码如下:
set rs_1 = server.createobject("adodb.recordset")
sql = "SELECT a.htbh, a.gys, a.htnr, a.htj, Sum(b.fkje) AS fkje_hj, nz(a.htj)-nz(Sum(b.fkje)) AS sqje_hj FROM htsx AS a LEFT JOIN fkmx AS b ON a.htbh=b.htbh GROUP BY a.htbh, a.gys, a.htnr, a.htj HAVING a.htbh='XM-002'"
rs_1.open sql,conn,1,1
页面输出:
<%=rs_1("htj")%>
<%=rs_1("sqje_hj")%>
但最后结果还没有显示。
请各位朋友帮个大忙~~~本人将不胜感激!在此先表示感谢了~~~