Cant seem to filter Dataset table by a value

M

mike11d11

I cant seem to filter down my dataset table by criteria in expression.
Can someone tell me why I still have the same amount of rows after I
use this filter select option.



Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Me.WorkListTableAdapter.Fill(Me.SQLDataSet.WorkList)

MsgBox(Me.AccuLogic_SQLDataSet.WorkList.Rows.Count)


End Sub



Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click

Me.SQLDataSet.Tables("WorkList").Select("DSK = '999'", "DSK")

End Sub
 
G

Guest

That is because

Me.SQLDataSet.Tables("WorkList").Select("DSK = '999'", "DSK")

will return a array of datarows

so you use this filetr like this

for each dr as datarow in Me.SQLDataSet.Tables("WorkList").Select("DSK =
'999'", "DSK")

debug.writeline(dr.item(0))

next

You might consider using a dataview wich gives you some more flexibility
with databinding


regards

Michel Posseth [MCP]
 
C

Cor Ligthert [MVP]

Was the same answer
:_)

Cor

Michel Posseth said:
That is because

Me.SQLDataSet.Tables("WorkList").Select("DSK = '999'", "DSK")

will return a array of datarows

so you use this filetr like this

for each dr as datarow in Me.SQLDataSet.Tables("WorkList").Select("DSK =
'999'", "DSK")

debug.writeline(dr.item(0))

next

You might consider using a dataview wich gives you some more flexibility
with databinding


regards

Michel Posseth [MCP]




mike11d11 said:
I cant seem to filter down my dataset table by criteria in expression.
Can someone tell me why I still have the same amount of rows after I
use this filter select option.



Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Me.WorkListTableAdapter.Fill(Me.SQLDataSet.WorkList)

MsgBox(Me.AccuLogic_SQLDataSet.WorkList.Rows.Count)


End Sub



Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click

Me.SQLDataSet.Tables("WorkList").Select("DSK = '999'", "DSK")

End Sub
 
M

mike11d11

I'm trying to get to where I can filter down my datatable to see
specific records. Instead of the debug line, what code could i use to
view only these accounts. I tried taking these rows and adding them to
another table but it gives me an error saying these rows already belong
to a table?
 
R

RobinS

Are you using data binding? You can easily filter
it with the associated binding source.

myBindingSource.Filter = "DSK = '999'"

Or create a DataView object (which is bindable, by the way)
and then filter it:

Dim myDataView = New DataView(SQLDataSet.Tables("WorkList"))
myDataView.Filter = "DSK = '999'"

I think if you want to read through the rows of the DataView,
you have to cast it as a table using the ToTable method.

Hope that helps.
Robin S.
 
C

Cor Ligthert [MVP]

Mike,

You never can add rows from one table to anothere.

The datarows have themselves no description of the items, those are in the
datacolumns.

The only thing you can do is make a datatable.copy and than filter that one,

Cor
 

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

Top