Victor Charles
asked on
Help with filtering data from DataTable
Hi,
I'm trying the code below to filter data from a DataTable, when I use C1TrueDBGrid1.DataSource = FilteredDT I get the correct number of records but I need to display only two columns, when I tried the code below:
Me.C1TrueDBGrid1.DataSourc e = FilteredDT.DefaultView.ToT able(True, New String() {"SN", "NAS"})
Only one record is displayed. How do I get the correct number of records along with the columns I want to display?
Dim SearchCriteria As String = "LinkAID <> -1 AND CHPT > 103 AND CHPT < 106"
Dim FilteredDT As DataTable
Dim DV As New DataView(dtsetLinkBEL.Tabl es(0), SearchCriteria, Nothing, DataViewRowState.CurrentRo ws)
FilteredDT = DV.ToTable
If FilteredDT.Rows.Count > 0 Then
' C1TrueDBGrid1.DataSource = FilteredDT
Me.C1TrueDBGrid1.DataSourc e = FilteredDT.DefaultView.ToT able(True, New String() {"SN", "NAS"})
End If
Thanks,
Victor
I'm trying the code below to filter data from a DataTable, when I use C1TrueDBGrid1.DataSource = FilteredDT I get the correct number of records but I need to display only two columns, when I tried the code below:
Me.C1TrueDBGrid1.DataSourc
Only one record is displayed. How do I get the correct number of records along with the columns I want to display?
Dim SearchCriteria As String = "LinkAID <> -1 AND CHPT > 103 AND CHPT < 106"
Dim FilteredDT As DataTable
Dim DV As New DataView(dtsetLinkBEL.Tabl
FilteredDT = DV.ToTable
If FilteredDT.Rows.Count > 0 Then
' C1TrueDBGrid1.DataSource = FilteredDT
Me.C1TrueDBGrid1.DataSourc
End If
Thanks,
Victor
ASKER
Hi,
I'm converting data from an XML file to a datatable dtsetLinkBEL.Tables(0).
fsLinkBEL = New System.IO.FileStream(Appli cation.Sta rtupPath + "\linkSearch.xml", IO.FileMode.Open)
dtsetLinkBEL.Clear()
dtsetLinkBEL.ReadXml(fsLin kBEL)
fsLinkBEL.Close()
V.
I'm converting data from an XML file to a datatable dtsetLinkBEL.Tables(0).
fsLinkBEL = New System.IO.FileStream(Appli
dtsetLinkBEL.Clear()
dtsetLinkBEL.ReadXml(fsLin
fsLinkBEL.Close()
V.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank You.
Make a query, import this to Access from SQL as query and make VBA code to filter it and you can add there as many fields you like in Access query builder. Then bound this to the application but this would be difficult to redistribute as there are two database bound together and they have hard coded paths. If the original database is Access then it's lot simpler. You can make a system or user data-source on the computer and bound it into a query in access external data-source.