下面这个是出现错误的语句:" select * from tblcpzl where 产品名称 like '" * " & " & Me.cxnr & " & " * "'"下面这个是正确的语句,但是没有"*"" select * from tblcpzl where 产品名称 like '" & Me.cxnr & "'"我想建立一个模糊查询,就想到了 like *某某产品* 的形式,请帮忙改一下第一句。

解决方案 »

  1.   

    " select * from tblcpzl where 产品名称 like '*" & Me.cxnr & "*'"
      

  2.   

    你的SQL语句本身是错的,不管在什么系统中都不能返回你预期的结果。这不是VB的问题。
    你还是先把SQL语句弄对了再说
      

  3.   

    "select * from tblcpzl where 产品名称 like '% "  & Me.cxnr  & " % '"
      

  4.   

    '参考
    SQL = "select 序号,工序类别,工序名称,计件单位,工价,是否停用 from WPI"
    SQL = SQL & " where 工序类别 & 工序名称 & 计件单位 & 工价 like '%" & Replace(Text1.Text, "'", "''") & "%' and 是否停用=0"
      

  5.   

    看看这里:
    http://topic.csdn.net/u/20080927/04/DA048AF0-F6DF-423B-9809-E659F1E05854.html
      

  6.   


    多了两个空格这样
    "select * from tblcpzl where 产品名称 like '%" & Me.cxnr & "% '"
      

  7.   

    +1
    楼主以为自己在使用Windows....
      

  8.   

    ACCESS环境中可以如下:
    " select * from tblcpzl where 产品名称 like '*" & Me.cxnr & "*'"
    VB6下ADO不认*,要用%:
    " select * from tblcpzl where 产品名称 like '%" & Me.cxnr & "%'"
      

  9.   

    请先说明SQL的使用地方
    Access
    SQLServer
    DB2
    等等。
    模糊查询的表示方法不一样。
      

  10.   

    select * from tblcpzl where 产品名称 like '%%" & Me.cxnr & "%% '"
      

  11.   

    "select * from tblcpzl where 产品名称 like '% "  & Me.cxnr  & " % '"
    "select * from tblcpzl where 产品名称 like '* "  & Me.cxnr  & " * '"
    这两个总有一个是对的,一般的前一个,但有是用后一个,其实我常常将“&”改为“+”,都是没问题的
      

  12.   

    请先说明SQL的使用地方
    Access
    SQLServer
    DB2
    等等。
    模糊查询的表示方法不一样。
      

  13.   

    " select * from tblcpzl where 产品名称 like '*" & Me.cxnr & " *'"
    这么写应该是正确的!