各位老师在sql语句中,在where后面直接使用字符串怎样书写,例如
dim str as string
rs.open "select * from 仓库情况 where str",cn,红色的部分对吗,请指正

解决方案 »

  1.   

    dim str as string 
    str="jhone"
    rs.open "select * from 仓库情况 where emp_name = '" & str & "' ",cn,
     
     
      

  2.   

    也有这么用
    dim str as string 
    if trim(text1.text) <> "" then
        str=" and name = '" & trim(text1.text) & "' "
    end if 
    rs.open "select * from 仓库情况 where 1=1 " & str,cn, 
      

  3.   

    我说的是where后面直接跟字符串,请问怎样书写
      

  4.   

    rs.open "select * from 仓库情况 where " &  str,
      

  5.   

    rs.open "select * from 仓库情况 where " &  str,cn
      

  6.   

    其实没看懂你在说什么,什么叫在where后面直接使用字符串?rs.open"select * from 仓库情况 where 数据库字段名 逻辑运算符 条件",cn,1,3
      

  7.   

    又想了想你可能是想要这样:
    dim str as string 
    str="name='王五'"'假设条件字段为name
    rs.open "select * from 仓库情况 where " & str ,cn,1,3
    或是:
    rs.open"select * from 仓库情况 where name='王五'",cn,1,3
      

  8.   

    dim str as string 
    str="jhone" 
    rs.open "select * from 仓库情况 where emp_name = '" & str & "' ",cn, 
      

  9.   

    以上回复不知有没有符合你条件的,关键是你的这个str 字符串具体是上面内容.
      

  10.   

    rs.open "select * from 仓库情况 where " & str ,cn,1,3 
    就是我要的情况,谢谢各位老师