把传递参数作为数据表中字段名的问题,麻烦高手帮忙看看

lidaixiang 2014-12-31 09:39:01
dim id1,id2
function tongji(id1,id2)
Set Rs = Server.CreateObject("Adodb.Recordset")
sql="select id from tb_vote where " & id1 & "=" & id2
Rs.Open sql,Conn,1,3
tongji=rsadd.recordcount
rs.close
end function
dim q11,q12,q13,q14
q1=tongji("t1",1)
q2=tongji("t2",2)
q3=tongji("t5",3)
q9=tongji("t9",4)

获取参数id1(数字型)且其值为id2的记录数,结果显示:

标准表达式中数据类型不匹配。

response.write 打印出SQL看不出有什么问题。数据库为ACCESS.请问是传递参数作为数据表字段名有误吗?什么原因,哪位高手麻烦帮助我看看。谢谢!祝各位新年快乐!
...全文
131 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
你确认你t1,t2,t5,t9字段都是数值型的?
xcgh 2015-01-02
  • 打赏
  • 举报
回复
还是打印看一下吧,应该是字段问题吧
huming_h 2015-01-01
  • 打赏
  • 举报
回复
把打印出来的sql语句到access里面执行一下看是否有结果? 会不会需要加上引号: select id from tb_vote where t1="1"

28,406

社区成员

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

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