I have a datatable that I fill when my application loads. This table is used to generate dataviews on the fly so I can maintain a listbox of unique values in the table.
I have the following code that works well the first time it is used, then shows no records after the second time. I am scratching my head over this one and for the life of me I can't see the problem. Maybe my understanding of tables and views is not up to par, but it looks as though it should work.
I have the following code that works well the first time it is used, then shows no records after the second time. I am scratching my head over this one and for the life of me I can't see the problem. Maybe my understanding of tables and views is not up to par, but it looks as though it should work.
VB.NET:
Sub RecordCnt ()
Dim dt As New DataTable
dt = Me.MyDataSet1.Names
Debug.Print("Row count")
Debug.Print(dt.Rows.Count) '<- this returns 1415 rows
Dim cf(0) As String
cf(0) = "Route"
Dim dv As New DataView
dv = dt.DefaultView.ToTable(True, cf).DefaultView
Debug.Print("Record count")
Debug.Print(dv.Count) '<- this returns 24 the first time I call this code 0 all others
End Sub