我刚学sql 现在在vb中 调用sql 语句 有问题不知道怎么写
有一个变量 x
现要查询 table 中 某个字段值 等于 x 的记录
select * from table where 条件该怎么写??
如果 变量是 字符型 怎么办  数值型又怎么办 (两者是不是不同)
我这样写的
.open "select * from table where 字段1名=x"
运行时有错误  

解决方案 »

  1.   

    字符性加''
    select * from table where 字段1名='x'
      

  2.   

    sql="select * from table where 字段1名="&x
    .open sql
      

  3.   

    字符型,X是变量名
    strSqlCmd="select * from table where 字段1名='" & x & "'"
    "
      

  4.   

    要看你的“字段1名”是什么类型的,INT类的要写成
    "& x &"  才能正确传值
    即.open "select  * from  table1  where 字段1名=" & x & " "或是字符型的,是应该为.open "select  * from  table1  where 字段1名='" & x & "' "