Problem with DataView.RowFilter Property (.NET Framework)

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I'm trying to use the RowFilter property...but with no luck...

Dim pdstSample As New DataSet
pdstSample.Tables.Add(New DataTable("tblSample"))
Dim pdtbSample As DataTable = pdstSample.Tables(0)
pdtbSample.Columns.Add(New DataColumn("fldSample"))
Dim pdrwSample As DataRow = pdtbSample.NewRow()
pdrwSample(0) = "Sample"
pdtbSample.Rows.Add(pdrwSample)
pdrwSample = pdtbSample.NewRow()
pdrwSample(0) = "Elpmas"
pdtbSample.Rows.Add(pdrwSample)
Dim pdvwSample As New DataView(pdtbSample)
MsgBox(pdvwSample.Table.Rows.Count)
pdvwSample.RowFilter = "fldSample = 'Sample'"
MsgBox(pdvwSample.Table.Rows.Count)


The two msgbox lines return 2 even though it should filter 1 row...please
help.......

Jag
 
Hi Jason,

You should check DataView's properties and not underlying DataTable ones.
MsgBox(pdvwSample.Count)
 
Thankyou, much appreciated. :)

Miha Markic said:
Hi Jason,

You should check DataView's properties and not underlying DataTable ones.
MsgBox(pdvwSample.Count)

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com


Jason Taylor said:
Hi,

I'm trying to use the RowFilter property...but with no luck...

Dim pdstSample As New DataSet
pdstSample.Tables.Add(New DataTable("tblSample"))
Dim pdtbSample As DataTable = pdstSample.Tables(0)
pdtbSample.Columns.Add(New DataColumn("fldSample"))
Dim pdrwSample As DataRow = pdtbSample.NewRow()
pdrwSample(0) = "Sample"
pdtbSample.Rows.Add(pdrwSample)
pdrwSample = pdtbSample.NewRow()
pdrwSample(0) = "Elpmas"
pdtbSample.Rows.Add(pdrwSample)
Dim pdvwSample As New DataView(pdtbSample)
MsgBox(pdvwSample.Table.Rows.Count)
pdvwSample.RowFilter = "fldSample = 'Sample'"
MsgBox(pdvwSample.Table.Rows.Count)


The two msgbox lines return 2 even though it should filter 1 row...please
help.......

Jag
 
Back
Top