locked
Problem with DataView.RowFilter - System.Data.EvaluateException. RRS feed

  • Question

  • When  I type expression

    name LIKE '*$% *'

    I get exception

    “Error in Like operator: the string pattern '*$% *' is invalid.”

     

    What can I do to avoid this exception?

    Regards

    Tuesday, June 16, 2009 2:06 PM

Answers

  • Hi kicaj

    Have a look at:

    "DataColumn.Expression Property"
    http://msdn.microsoft.com/en-us/library/system.data.datacolumn.expression(VS.80).aspx

    and you'll notice that this expression contains a special charachter that needs to be escaped. The % in your case.

    Change it to, for example;

                DataTable dt = new DataTable();
                dt.Columns.Add(new DataColumn("name", typeof(string)));
                string sql = "name LIKE '*$\\%'";
                DataRow[] rows = dt.Select(sql);

    HTH

    //Michael


    This posting is provided "AS IS" with no warranties.
    Wednesday, June 17, 2009 7:27 AM