在查询语句里面,字符串赋值用'"&变量&"',但是"&变量&"没见过啊。

解决方案 »

  1.   

    关键看你的SQL语句里需要的是数值型的还是其他的,数值型的不用'',其它类型的需要。
      

  2.   

    dim Str as string
    strSQL = "SELECT dsp_date_time from table where Id=" &  str & " And...."
    strSQL = "SELECT dsp_date_time from table where Id='" &  str & "' And...."知道为什么2条sql语句不一样吗?
    不是变量str的问题是,因为数据表table中的Id 字段的类型不一样
    第一个id是数值类型(如int,smallint)
    而第二个呢?Id为字符类型如char或varchar啊,所以变量前面要加2个单引号
      

  3.   

    我把源码写给大家看好了
    username=inputbox("please input user name")
    filter="sn=" & username
    command="select name,path from '"& iads.path &"' where "& filter &""
    其中iads.path是iads这个对象的一个属性,是字符串类型的,而filter明明是一个字符串啊,怎么他们用的就不一样呢,而且程序运行正常,没有错。