Question regarding DataRowView.RowFilter

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi There

I am having trouble with the DataRowView.RowFilter

I am giving subscribers to an asp.NET application the ability to search
through a large group of historical records based on a "Subject" field.

They have a textbox (txtSubjectCriteria) within which they enter search
criteria and then I have a radio button list that allows them to select
whether their entered criteria should be any part of a word or phrase, or a
whole word or phrase.

The any part of a word or phrase is easy and the filter string would be:
Filter = "Subject Like '%" & txtSubjectCriteria.Text & "%'"

I am, however, struggling with the whole word only option. The operators on
the DataRowView.RowFilter seem to be a bit limited ? I was expecting to be
able to use:
Filter = "Contains (Subject, '" & txtSubjectCriteria.Text & "')"
or something similar - but this does not seem to be a valid statement ?

Does anybody know how I can achieve this - I really need it to be done at
this level rather than with the original SQL statement.

Thanks for your help

Stuart
 
=?Utf-8?B?U3R1YXJ0?= said:
The any part of a word or phrase is easy and the filter string would
be: Filter = "Subject Like '%" & txtSubjectCriteria.Text & "%'"

I am, however, struggling with the whole word only option. The
operators on the DataRowView.RowFilter seem to be a bit limited ? I
was expecting to be able to use:
Filter = "Contains (Subject, '" & txtSubjectCriteria.Text & "')"
or something similar - but this does not seem to be a valid statement

Why would contains be accepted? Contains is not standard in SQL and Filter accepts just the basics
of standard SQL.
Does anybody know how I can achieve this - I really need it to be done
at this level rather than with the original SQL statement.

Yuo can make a custom filter, or this will work in some cases:

Filter = "Subject Like ' %" & txtSubjectCriteria.Text & "% '"

of coures it wont account for other whitespace.
 
Back
Top