asp连接access数据库中
dim strSql, strSql2
strSql="Update 东方不败 Set Sfhwhy='Y' where name='"&hy&"'"
conn2.Execute(strSql)
上述语句中的表名是东方不败,我们直接写到了查询语句中,是可行的,但遗憾的是,用参数来替代就是不行
Dim km
km="东方不败"
dim strSql, strSql2
strSql="Update "& km & "Set Sfhwhy='Y' where name='"&hy&"'"
conn2.Execute(strSql)
把参数赋值给km后,这就不行了
dim strSql, strSql2
strSql="Update "& "东方不败" & "Set Sfhwhy='Y' where name='"&hy&"'"
conn2.Execute(strSql)
还是直接用字符串,只不过是以字符串连接的方式,也是不行,不明白是什么原因,请高手指点下哈

Update语句中的表名不能用参数代替吗
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
4条回答 默认 最新
- beaconD 2015-06-12 00:47关注
可以,set前别缺空格,你打一下strSql
strSql="Update "& km & " Set Sfhwhy='Y' where name='"&hy&"'"本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报