FindRows search expression syntax?

A

Amy Chen

Hi,
I am trying to filter rows in a DataView, and I'm experimenting with
the .RowFilter and .FindRows members of the DataView class. I
understand that .RowFilter re-builds the indices and hurts
performance, so I'd like to use .FindRows if possible.

What I don't understand at the moment is the following:

1. When I use .RowFilter, I can use SQL-like syntax. For example,
let's say that I want to filter on user names that equal, do not
equal, contain, do not contain, start with, and do not start with a
string. So if I'm interested in rows where a username contains a
string, I can write

myDataView.RowFilter = "userName LIKE '%_string_goes_here_%'"

and I get back my results.

2. But when I use .FindRows, it seems that I can only search for
values that equal the parameter that I pass to .FindRows. For
example, I can say:

myDataView.Sort = "userName ASC";
myDataView.FindRows("amy");

But how do I use .FindRows to search for values that do not equal
"amy", or contain "amy", or start with "amy"?

Does .FindRows allow me to do this, or does it support only a simple
equality search?

Thanks in advance,
Amy Chen
 
M

Miha Markic [MVP C#]

Hi Amy,

You might use DataTable.Select method to do a free search.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top