找错误

supchen 2002-05-12 05:39:28
set score=server.createobject("ADODB.Command")
score.activeconnection= "database1"
score.commandtext="select count(*) from bmb where schoolname='"&schoolname&"' and kaoshenglb='"&kaoshenglb&"' and kaoshilb='"&kaoshilb&"';"
set sc=score.execute
Nuscore=sc("count(*)")
在最后一句有什么错误?
...全文
85 7 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
tripofdream 2002-05-12
  • 打赏
  • 举报
回复
需要给计算字段一个别名(alias)来作为字段名引用.
SQL语句结加";"是正确的,可以用";"来一次执行多个SQL语句.
超级大笨狼 2002-05-12
  • 打赏
  • 举报
回复
Nuscore=sc("count(*)")
你混了sql语句和vbs代码,"count(*)"在这句话里是不会被当作sql运算的,一定要用中间变量as一下才能够达到你的目的。
还有and kaoshilb='"&kaoshilb&"';"多了一个分号
cmsoft 2002-05-12
  • 打赏
  • 举报
回复
错了,最后一句改成:

Nuscore=sc("num")
cmsoft 2002-05-12
  • 打赏
  • 举报
回复

Sql="select count(*) as num from bmb where schoolname='"&schoolname&"' and kaoshenglb='"&kaoshenglb&"' and kaoshilb='"&kaoshilb&"'"
set sc=score.execute(Sql)
Nuscore=sc("count(*)")
sjhasp 2002-05-12
  • 打赏
  • 举报
回复
取出记录总数给Nuscore
cmsoft 2002-05-12
  • 打赏
  • 举报
回复
score.commandtext="select count(*) from bmb where schoolname='"&schoolname&"' and kaoshenglb='"&kaoshenglb&"' and kaoshilb='"&kaoshilb&"';"
这句最后的分号去掉啊
秋风ss落叶 2002-05-12
  • 打赏
  • 举报
回复
错!
score.commandtext="select count(*) AS xxx from bmb where schoolname='"&schoolname&"'

...

Nuscore=sc("xxx")

28,408

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧