I have created an SQL Connection, than a DataAdapter which fills a dataset, and now the problem: how do i filter records in the dataset without requering the database? In vb6 the job was done by recordset.filter property how do i do it in ADO.Net
To filter your data, you can either create a DataView object, or use the Select() method of the DataTable class.
Select() returns an array of DataRow objects. Here's a partial sample of how to use this feature:
Dim cn as SqlConnection
Dim da as SqlDataAdapter
Dim ds as DataSet
Dim row as DataRow
Dim myRows() as DataRow
|
'Make your connection
'Create your DataAdapter
'Fill your DataSet
|
myRows = ds.Tables("Customers".Select("type='retail'", "name ASC"
For Each row in myRows
'processing here
Next
This will return all the rows in the "Customers" DataTable that have a "type" of "retail" sorted by "name."
Here's how use a DataView object to filter data:
'Dim and instantiate your Connection, DataAdapter, DataSet objects as before.
Dim myDataView as DataView
Dim myRow as DataRowView
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.