sddtlm8 2015-06-11 14:59 采纳率: 0%
浏览 2354
已采纳

Update语句中的表名不能用参数代替吗

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)
还是直接用字符串,只不过是以字符串连接的方式,也是不行,不明白是什么原因,请高手指点下哈

  • 写回答

4条回答 默认 最新

  • beaconD 2015-06-12 00:47
    关注

    可以,set前别缺空格,你打一下strSql
    strSql="Update "& km & " Set Sfhwhy='Y' where name='"&hy&"'"

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?