filter dataset??

  • Thread starter Thread starter John Pether
  • Start date Start date
J

John Pether

I have a dataset and i want to filter it into a new dataset or reader. I
have the following code below but do not know how to finish it. I want to
inport all rows where the TypeName column = a certain value (premier plus)
Some help would be appreciated:)

Dim links As New DNSite.LinksDB()

Dim myDS As DataSet

myDS = links.GetLinks(CatID)

' filter dataset for premier plus links
' and bind to the datalist control

Dim pluslinks As New DataSet()

pluslinks.Tables.Add(myDS.Tables("tblLinks").Clone)

pluslinks.Tables(0).ImportRow(myDS.Tables("tblLinks").???
 
Hi john,
Here is the code which updates to a RowsCollection from a
DataSet. Basically, what you are looking for is to filter
the rows from a Dataset and store that in a DataSet. If,
what i understood is correct, here is the similar sort of
code which just filters some records from the DataTable on
filtering to different DataRows collection.

'Assume we have a DataTable Dt
'Dim strExpr As String
'Dim FilteredRows() As DataRow
'strExpr = "RegistrationDate >= #12/10/2002# and
RegistrationDate <= #" + Date.Today().ToShortDateString
+ "#"
-- put the filtered expression into a DataRows Collection
'FilteredRows = Dt.Select(strExpr)
 
Does this help :

YourDataSet.Tables[0].Select("Col = value")

This will return a datatable.
 
You can bind to a DATAVIEW,


When binding, bind to the DEFAULTVIEW, them set a row filter on this view.

myDS.Tables[0].Select("TypeName=Premier"') will return a DATATABLE with the
rows in that match the filter, but if its just for binding why bother
creating a new dataset with a new table, why not just bind to a dataview.

Cheers

Steve


John Pether said:
Are you saying that instead of filtering the full dataset to another dataset
and dinding it to the datalist, I can just filter the master dataset and
bind that to the datalist?

so if I have a datalist plusDL I could do this??? Actually, tried that and
it doesn't work...LOL

plusdl.DataSource = myDS.Tables[0].Select("TypeName=Premier")

I presume <code>myDS.Tables[0].Select("TypeName=Premier"')</code> selects
all rows that contain TypeName=Premier???...hmmmm getting confused now

Thx for your help:):)




Steve Drake said:
Does this help :

YourDataSet.Tables[0].Select("Col = value")

This will return a datatable.




John Pether said:
I have a dataset and i want to filter it into a new dataset or reader. I
have the following code below but do not know how to finish it. I want to
inport all rows where the TypeName column = a certain value (premier plus)
Some help would be appreciated:)

Dim links As New DNSite.LinksDB()

Dim myDS As DataSet

myDS = links.GetLinks(CatID)

' filter dataset for premier plus links
' and bind to the datalist control

Dim pluslinks As New DataSet()

pluslinks.Tables.Add(myDS.Tables("tblLinks").Clone)

pluslinks.Tables(0).ImportRow(myDS.Tables("tblLinks").???
 
Back
Top