[求助]vba数据库问题
您好:我用vba连数据库,但出现一个问题:当使用如下代码试
cmd.CommandText = "INSERT INTO valveblock VALUES ('leoblock','2','success')"
程序可正常使用
-----------------------------------------------------------------------------
但当我想用变量传递数据时:如
dim x as string
x="leoblock"
cmd.CommandText = "INSERT INTO valveblock VALUES ('x','2','success')"
或
cmd.CommandText = "INSERT INTO valveblock VALUES (x,'2','success')"
此时程序报错,不只有无方法解决
请高手指点!谢谢! SQL语句写错了. 应写为
cmd.CommandText = "INSERT INTO valveblock valueS ('" & x &"','2','success')"
页:
[1]