RowFilter on DataView

  • Thread starter Martyn Fewtrell
  • Start date
M

Martyn Fewtrell

I'm sure this is straight forward but it has me stumped! (I assume this can
be done but cant find any online examples.)

I want to filter a single column in a DataView for more than one result but
cannot work out syntax that works using Vb.Net.

Let say I have a column (Names) with a range of names in it but want to
select only those called "John" and "Fred". The syntax

dvMyView.RowFilter = "Name = 'John'" will select those called John without
any issue.

I've tried all the obvious options like 'John' AND 'Fred' but cant seem to
work out the correct syntax.

Also if I want to Filter across several columns is this possible?

The only way I can make this work is to Filter the first Table using the
criteria on the first column and then use the results to create a second
table which I then Filter using the criteria on the second column. I would
then have to output the results from the second table. I am sure there must
be an easier way of doing this. (I am aware that I could easily just query
the database for the correct results in the first place but was trying to
avoid this!

You have my apologise if these are particularly dense questions!
 
M

Martyn Fewtrell

Thanks Scott

I haven't had a chance to try it out yet.

I had thought that I had tried that combination last week (I tried all those
options which appeared logical).

I assume therefore that I could string together a number of variables

dvMyDataView.RowFilter = "one & two & three & four"

where each option is generated dynamically from a selection box to be
something like:

one = "Name = 'John'"

two = "AND Name = 'Fred'"

three = "And Surname = 'Jones'"

etc


--
Martyn Fewtrell
(e-mail address removed)

http://www.networkclub.co.uk
 

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

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top