ASP+SQL 高手来帮我看下~~小弟谢谢了~~急急急!!!

来源:百度知道 编辑:UC知道 时间:2024/05/12 02:10:04
有5个表 year,month,yclsj,nsrxx ,hymx
year(year_id,year_mc) 代表年
hymx(hy_id,hy_mc) 代表行业
month(month_id,month_mc) 代表月
nsrxx(nsr_id,nsr_mc,nsr_sbh) 代表用户
yclsj(ycl_id,qbhysl,month_id,year_id,nsr_id,hy_id) 代表原材料,bqhy_sl表示数量,month_id,year_id,nsr_id分别与year,month,nsrxx,hymx表里的month_id,year_id,nsr_id,hy_id相同。
现在要设置一个时间段 查询选中用户(nsr_sbh)的原材料数量(求和)

我在SQL的查询分析器里查出来了
代码是:
SELECT sum(yclsj.bqhy_sl) as 原材料数量总和 FROM ((yclsj INNER JOIN nsrxx ON yclsj.nsr_id = nsrxx.nsr_id and nsrxx.nsr_sbh = '输入用户识别号' ) INNER JOIN month ON yclsj.month_id = month.month_id and month.month_mc >='月1' and month.month_mc <='月2') INNER JOIN year ON yclsj.year_id = year.year_id and year.year_mc>='年1' and year.year_mc<='年2' group by yclsj.hy_id

但是在ASP页面语言里弄不出来
这是我一部分的ASP语言
<html>
<head>
<title>按行业综合查询</title>
<style>
p,select,table {font-size: 12pt}
&

browseinfo3.asp
<%
dim txtye1,txtmo1,txtye2,txtmo2
txtye1=request("txtye1")
txtmo1=request("txtmo1")
txtye2=request("txtye2")
txtmo2=request("txtmo2")
dim cnn,sql,rs
set cnn=server.createobject("adodb.connection")
cnn.connectionstring="provider=sqloledb; data source=91.48.24.1;" & "uid=xuliang; pwd=123; database=sjcj"
cnn.open
sql="SELECT sum(yclsj.bqhy_sl) as 原材料数量总和 FROM ((yclsj INNER JOIN nsrxx ON yclsj.nsr_id = nsrxx.nsr_id and nsrxx.nsr_sbh = '输入用户识别号' ) INNER JOIN month ON yclsj.month_id = month.month_id and month.month_mc >='"&txtmo1&"'and month.month_mc <='"&txtmo2&"') INNER JOIN year ON yclsj.year_id = year.year_id and year.year_mc>='"&txtye1&"'and year.year_mc<='"&txtye2&"'group by yclsj.hy_id "
Set rs=server.createobject("adodb.reco