[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 159
  • Last Modified:

in ADO have one function is Filter. What is the same function in ADO.NET?


I have learned ado that it has a function is Filter. But I don't know if ADO.NET can do that?
Please help and provide example is appreciated...

Thank you.
BM.
0
veayou
Asked:
veayou
2 Solutions
 
DabasCommented:
Hi veayou,
In general I doubt there is anything in ADO that you cannot do in ADO.NET
But do remember, ADO.NET is NOT a new version of ADO. All they share is the name.

The way to go is DataViews. I suggest you read the help on DataView in general and on RowFilter in particular

Dabas
0
 
arif_eqbalCommented:
If you have datatable in ADO.NET then
create a view of it
Dim DV as dataView=New DataView(YourDataTable)
DV.RowFilter="Key_Field='The Value'"

then DV contains only the Filtered Rows
However unlike classic ADO the underlying table i.e. YourDataTable still is unfiltered and will show all records

There's another way too in case you want to avoid DataViews
You can use the Default view of the dataTable

YourDataTable.DefaultView.RowFilter="Key_Field='The Value'"
Then

YourDataTable.DefaultView will contain the filtered rows (the underlying table is still same)
So if you are using dataBinding and want to mimic Classic ADO where the recordset used to get filtered what you can do is Bind on the YourDataTable.DefaultView rather than the datatable itself.



0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now