0

我有一个具有多个条件的 BindingSource 过滤器。这样做的原因是我可以有一个search_textbox来查找特定记录...

不过,我有一个问题,我有一个稍微更永久的条件“ Status LIKE ' {0} ' AND... ”,但是一旦我输入任何内容,该限制就会被忽略。我以为'AND'会解决这个问题,但显然我错了。

bs.Filter = String.Format("Status LIKE '*{0}*' AND Customer_Code LIKE '*{1}*' OR Customer_Name LIKE '*{1}*' OR Customer_JobNumber LIKE '*{1}*' OR Customer_Date LIKE '*{1}*' OR Order_Number LIKE '*{1}*'", select, textBox1.Text);

有什么建议吗?谢谢

赫尔曼·维奎尔

编辑:

抱歉,可能应该提到这在 TextChanged 事件中重复出现。

4

1 回答 1

1

您不需要在您的条件周围添加几个括号吗?

bs.Filter = String.Format("Status LIKE '*{0}*' AND ( Customer_Code LIKE '*{1}*' " + 
                          "OR Customer_Name LIKE '*{1}*' OR Customer_JobNumber LIKE '*{1}*' " + 
                          "OR Customer_Date LIKE '*{1}*' OR Order_Number LIKE '*{1}*')", 
                          select, textBox1.Text);

意思是STATUS LIKE '*<select>* AND (one or more the following condition is true)

于 2013-05-02T11:10:35.887 回答