asp 字段求和问题

fanmin330 2008-04-02 09:21:29
<%
dim rsTest,strSqlTest,rsTemp,strSqlTemp,rsPS,strSqlPS,intPrjID,intPSID,intStudentID
dim intTotalMark,intSSCount,intSSMark,intMSCount,intMSMark,intBCount,intBMark
dim strPrjName,dtmStartTime,intLimitTime,intState,dtmStartDate,dtmEndDate
if checkStudentLogin() = false then '验证考生是否已登录
response.redirect "student_login.asp"
end if
intPrjID = CLng(request.querystring("prjid"))
intStudentID = request.cookies("aoyi")("studentid")
'读取考试信息
strSqlTest = "select starttime,endtime,limittime,prjname,ss_count,ms_count,b_count from project where prjid=" & intPrjID
set rsTest = server.createobject("ADODB.Recordset")
rsTest.open strSqlTest,G_CONN,1,1
'验证是否存在本次考试
if rsTest.bof and rsTest.eof then
response.write "<script>alert('此次考试不存在!');window.open('index_main.asp','_self');</script>"
rsTest.close
set rsTest = nothing
response.end
end if
strPrjName = rsTest("prjname")
intSSCount = rsTest("ss_count")
intSSMark = "select sum(fenzhi) As from subject by type = 1" '这里出错拉,这个语法该怎么写?
intMSCount = rsTest("ms_count")
intMSMark = "select sum(fenzhi) As from subject by type = 2"
intBCount = rsTest("b_count")
intBMark = "select sum(fenzhi) As from subject by type = 3"
intTotalMark = intSSMark + intMSMark + intBMark
dtmStartDate = rsTest("starttime")
dtmEndDate = rsTest("endtime")
intLimitTime = rsTest("limittime")
rsTest.close
...全文
209 点赞 收藏 22
写回复
22 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
tangqiaojie 2008-04-03
[Quote=引用 18 楼 fanmin330 的回复:]
intSSMark = G_CONN.execute("select sum(fenzhi) from subject Where type = 1 and courseid=" & intCourseID)(0)

我加咯句 and courseid=" & intCourseID
怎么读出courseid=0 呢?
[/Quote]
不太明白你的意思
回复
myvicy 2008-04-03
系统报的什么错误呢?
回复
myvicy 2008-04-03
1、对于表名和字段名最好两边加[],以防止使用保留字做名称出错.
2、条件为字符串或者组合的字符串时,两边要用单引号。
回复
fanmin330 2008-04-02
高手们,能加我QQ说吗? 4607045
回复
fanmin330 2008-04-02
intSSMark = G_CONN.execute("select sum(fenzhi) from subject Where type = 1 and courseid=" & intCourseID)(0)

我加咯句 and courseid=" & intCourseID
怎么读出courseid=0 呢?
回复
tangqiaojie 2008-04-02


intSSMark = G_CONN.execute("select sum(fenzhi) from subject where type = 1")(0)
回复
ycyulei 2008-04-02
intSSMark = G_CONN.execute("select sum(fenzhi) from subject By type = 1")(0)

改成:
intSSMark = G_CONN.execute("select sum(fenzhi) from subject Where type = 1")(0)
回复
hookee 2008-04-02
set rs = createobject("adodb.recordset")
rs.CursorLocation = 3
sql = "select sum(fenzhi) from [subject] where [type] = 1"
rs.open sql, G_CONN, 1,1
intSSMark = rs(0)
sql = "select sum(fenzhi) from [subject] where [type] = 2"
rs.open sql, G_CONN, 1,1
intMSMark = rs(0)
sql = "select sum(fenzhi) from [subject] where [type] = 3"
rs.open sql, G_CONN, 1,1
intBMark = rs(0)
rs.close
set rs = nothing
回复
fanmin330 2008-04-02
intSSMark = G_CONN.execute("select sum(fenzhi) from subject by type = 1")(0)

这句还是不对啊?

Microsoft JET Database Engine 错误 '80040e14'

FROM 子句语法错误。

/testing.asp,行 50
回复
ab520ah 2008-04-02
http://qzshi.com
可以参考下
回复
fanmin330 2008-04-02
是的啊
回复
hookee 2008-04-02
subject是另外一张表吗?
回复
tangqiaojie 2008-04-02
你...写了SQL语句,不运行怎么有结果啊....当然就那样显示拉


intSSMark = G_CONN.execute("select sum(fenzhi) from subject by type = 1")(0)
回复
fanmin330 2008-04-02
哦..谢谢提醒哈,下次改正哈
回复
tangqiaojie 2008-04-02

dim rsTest,strSqlTest,rsTemp,strSqlTemp,rsPS,strSqlPS,intPrjID,intPSID,intStudentID
dim intTotalMark,intSSCount,intSSMark,intMSCount,intMSMark,intBCount,intBMark
dim strPrjName,dtmStartTime,intLimitTime,intState,dtmStartDate,dtmEndDate
if checkStudentLogin() = false then '验证考生是否已登录
response.redirect "student_login.asp"
end if
intPrjID = CLng(request.querystring("prjid"))
intStudentID = request.cookies("aoyi")("studentid")
'读取考试信息
strSqlTest = "select starttime,endtime,limittime,prjname,ss_count,ms_count,b_count from project where prjid=" & intPrjID
set rsTest = server.createobject("ADODB.Recordset")
rsTest.open strSqlTest,G_CONN,1,1
'验证是否存在本次考试
if rsTest.bof and rsTest.eof then
response.write " <script>alert('此次考试不存在!');window.open('index_main.asp','_self');</script>"
rsTest.close
set rsTest = nothing
response.end
end if
strPrjName = rsTest("prjname")
intSSCount = rsTest("ss_count")
intSSMark = "select sum(fenzhi) As from subject by type = 1" '这里出错拉,这个语法该怎么写?
intMSCount = rsTest("ms_count")
intMSMark = "select sum(fenzhi) As from subject by type = 2"
intBCount = rsTest("b_count")
intBMark = "select sum(fenzhi) As from subject by type = 3"
intTotalMark = intSSMark + intMSMark + intBMark
dtmStartDate = rsTest("starttime")
dtmEndDate = rsTest("endtime")
intLimitTime = rsTest("limittime")
rsTest.close



这样大家看都方便,呵呵。
回复
tangqiaojie 2008-04-02
你应该把你代码用“插入原代码”的方式插入的,就想这样:

dim rsTest,strSqlTest,rsTemp,strSqlTemp,rsPS,strSqlPS,intPrjID,intPSID,intStudentID
dim intTotalMark,intSSCount,intSSMark,intMSCount,intMSMark,intBCount,intBMark
dim strPrjName,dtmStartTime,intLimitTime,intState,dtmStartDate,dtmEndDate
if checkStudentLogin() = false then '验证考生是否已登录
response.redirect "student_login.asp"
end if
intPrjID = CLng(request.querystring("prjid"))
intStudentID = request.cookies("aoyi")("studentid")
'读取考试信息
strSqlTest = "select starttime,endtime,limittime,prjname,ss_count,ms_count,b_count from project where prjid=" & intPrjID
set rsTest = server.createobject("ADODB.Recordset")
rsTest.open strSqlTest,G_CONN,1,1
'验证是否存在本次考试
if rsTest.bof and rsTest.eof then
response.write " <script>alert('此次考试不存在!');window.open('index_main.asp','_self');</script>"
rsTest.close
set rsTest = nothing
response.end
end if
strPrjName = rsTest("prjname")
intSSCount = rsTest("ss_count")
intSSMark = "select sum(fenzhi) As from subject by type = 1" '这里出错拉,这个语法该怎么写?
intMSCount = rsTest("ms_count")
intMSMark = "select sum(fenzhi) As from subject by type = 2"
intBCount = rsTest("b_count")
intBMark = "select sum(fenzhi) As from subject by type = 3"
intTotalMark = intSSMark + intMSMark + intBMark
dtmStartDate = rsTest("starttime")
dtmEndDate = rsTest("endtime")
intLimitTime = rsTest("limittime")
rsTest.close


回复
fanmin330 2008-04-02
还是不对啊,
前台里显示的是这样的

姓名:s 总分:select sum(fenzhi) As fz from subject where type = 1select sum(fenzhi) As fz from subject where type = 2select sum(fenzhi) As fz from subject where type = 3 考试时间:24分钟
回复
hookee 2008-04-02
intSSMark = "select sum(fenzhi) As fz from subject where type = 1"
回复
fanmin330 2008-04-02
intSSMark = "select sum(fenzhi) As from subject by type = 1"

这句有错没的啊?
回复
fanmin330 2008-04-02
要不我把整套代码发给你,你看下。好不?
回复
加载更多回复
相关推荐
发帖
ASP
创建于2007-09-28

2.8w+

社区成员

ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
申请成为版主
帖子事件
创建了帖子
2008-04-02 09:21
社区公告
暂无公告