Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Compound conditional in a DataView RowFilter

Status
Not open for further replies.

SBendBuckeye

Programmer
Joined
May 22, 2002
Messages
2,166
Location
US
Hello all,

I am trying to filter a DataView on 2 columns. When I first set the filter it does not appear to take (eg DataView.Count = DataTable.Rows.Count), not less as should be the case with the Filter set. I have tried various permutations of the following:
Code:
Column1 = 'Value1' OR Column2 = 'Value2'
(Column1 = 'Value1') OR (Column2 = 'Value2')
((Column1 = 'Value1') OR (Column2 = 'Value2'))
Am I missing something obvious here? Thanks in advance!
 
Code:
yourDataView.RowFilter = "Column1 = 'Value1' OR Column2 = 'Value2'"

The syntax is correct if both Column1 and Column2 are of type String.

If Column1's name or Column2's name contains spaces or is some kind of reserved word, you should place them between brackets.

Code:
yourDataView.RowFilter = "[Column1] = 'Value1' OR [Column2] = 'Value2'"


Now another reason why the Dataview.count could be that all the records have column1 set to 'Value1' or column2 set to 'Value2'.... ?

Hope it helps somehow !

---
If gray hair is a sign of wisdom, then talk like a pirate ninja monkey if you get the time to get funky once a week.
Wo bu zhi dao !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top