zoukankan      html  css  js  c++  java
  • like查询


    Hello,

    How can I use special characters % and * in DataView.RowFilter
    expression in which I have already LIKE statement?

    I am using a DataView to displaying a records from datatable, I allow
    users to enter the string which will be pasted into RowFilter in such way

    MyDataView.RowFilter= myColumn LIKE '%"+MyTextBox.Text+"%'";

    The problem is when user enters string which contains % or * I get an
    exception:
    System.Data.EvaluateException: Error in Like operator: the string
    pattern ' ' is invalid.

    DataTable can contain strings with those characters and users must be
    able to define filter with them.


    -------------------------------------------------------------------------------

    According to help you should escape both % and * into square brackets: % ->
    [%] and * -> [*].

    help:
    "Both the * and % can be used interchangeably for wildcards in a LIKE
    comparison. If the string in a LIKE clause contains a * or %, those
    characters should be escaped in brackets ([]). If a bracket is in the
    clause, the bracket characters should be escaped in brackets (for example
    [[] or []]). "
  • 相关阅读:
    将Infopath转成PDF
    调用MOSS API取document时出现out of memeory错误
    jquery dialog中mvc客户端验证无效
    Windows Service开发点滴20130622
    CentOS
    nginx
    VIM
    nodejs weixin 笔记
    nodejs mysql
    nodejs 笔记
  • 原文地址:https://www.cnblogs.com/tuantuan/p/418766.html
Copyright © 2011-2022 走看看