我现在碰到一个有关AdoDataSet的Filter的问题,当Filter:='name like %中国% and status=''1'' or status=''1'''的时候没有问题,如果将它改为:
Filter:='name like %中国% and (status=''1'' or status=''1'')'将会出现错误:
 应用程序使用的参数或者类型不正确,或者不在可以接受的范围之内,要不就是与其他数据冲突。现在是山穷水尽了,恳请高手赐教!!!!

解决方案 »

  1.   

    '(name like %中国%) and (status=''1'' or status=''1'')'
    试试
      

  2.   

    adodataset.filter:='(name like '+''''+'%'+'中国'+''''+'%'+') and (status='+'1'+' or status='+'1'+')'
      

  3.   

    showmessage('(name like '+''''+'%'+'中国'+'%'+''''+') and (status='+'1'+' or status='+'1'+')')adodataset.filter:='(name like '+''''+'%'+'中国'+'%'+''''+') and (status='+'1'+' or status='+'1'+')'
      

  4.   

    Note: include a space between comparison values and comparison operators in filter expressions. For instance, ensure that there is a space after the field name and before the operator.注意:在过滤表达式的比较值和比较符中间要包括一个空格。例如,要保证在一个字段名之后和一个比较符之前有一个空格。---------------
    摘自deliphi6在线帮助
      

  5.   

    Filter:='name like %中国% and (status=''1'' or status=''1'')'
    帮你分析一下错误,个人意见:
    (status=''1'' or status=''1'')此写法得到的是布尔类型,跟前面字符串不一致,所以会出现错误。
    楼上的应该行的通
      

  6.   

    这样吧 我这没有环境 你在分析里写一个能执行的 让后不就是在delphi环境下 拼字符串吗
    你试试!
      

  7.   

    Filter:='name like '*中国*' and (status=''1'' or status=''1'')'
      

  8.   

    Filter中无法使用复杂的条件。
    使用OnFilterRecord过滤
      

  9.   

    应该改为,(Filter:='name like '*中国*')and((status=''1'') or (status=''1'')')
    试一下吧,
      

  10.   

    写错了,
    应该改为,Filter:=('name like '*中国*')and((status=''1'') or (status=''1'')')
    试一下吧,可能是Or的级数比较低吧
      

  11.   

    Filter:='name like %中国%' + 'and status=' +'''' +'1' +'*' +'''' +'or status=' +'''' +'1' +'*' +'''';
      

  12.   

    filter:=' name like ''%中国%'' and (status=''1'' or status=''1'') 'status如果不是字符串,就不要用''号了。
      

  13.   

    不要试了
    Delphi中ADO的Filter和Find方法不好用
    总出错
    放弃吧
      

  14.   

    我也遇到了这个问题,由于是中文提示,所以它是ADO的错误,通过查MSDN得知:AND 和 OR 在级别上没有先后之分。可使用括号将子句分组。但不能象以下示例那样先将由 OR 联接的子句分组然后将该组用 and 联接到其他子句。
    (LastName = 'Smith' OR LastName = 'Jones') AND FirstName = 'John'
    与之相反,可以构造如下形式的筛选:
    (LastName = 'Smith' AND FirstName = 'John') OR (LastName = 'Jones' AND FirstName = 'John')
    在 LIKE 子句中,可在样式的开头和结尾使用通配符(如 LastName Like '*mit*'),或者只在结尾使用通配符(如,LastName Like 'Smit*')。 
    知道了原因,那怎么修改就看各自的本事了!