Solved

Help with filtering data from DataTable

Posted on 2014-02-17
4
223 Views
Last Modified: 2014-02-18
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.DataSource = FilteredDT.DefaultView.ToTable(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.Tables(0), SearchCriteria, Nothing, DataViewRowState.CurrentRows)
        FilteredDT = DV.ToTable
        If FilteredDT.Rows.Count > 0 Then
            ' C1TrueDBGrid1.DataSource = FilteredDT
            Me.C1TrueDBGrid1.DataSource = FilteredDT.DefaultView.ToTable(True, New String() {"SN", "NAS"})
        End If

Thanks,

Victor
0
Comment
Question by:vcharles
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 14

Expert Comment

by:Matti
ID: 39866456
Hi!

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.
0
 

Author Comment

by:vcharles
ID: 39866562
Hi,

I'm converting data from an XML file to a datatable dtsetLinkBEL.Tables(0).

 fsLinkBEL = New System.IO.FileStream(Application.StartupPath + "\linkSearch.xml", IO.FileMode.Open)
        dtsetLinkBEL.Clear()
        dtsetLinkBEL.ReadXml(fsLinkBEL)
        fsLinkBEL.Close()

V.
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 39867995
Change this

Me.C1TrueDBGrid1.DataSource = FilteredDT.DefaultView.ToTable(True, New String() {"SN", "NAS"})

to

Me.C1TrueDBGrid1.DataSource = FilteredDT.DefaultView.ToTable(False, New String() {"SN", "NAS"})
0
 

Author Closing Comment

by:vcharles
ID: 39868331
Thank You.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
how to remove error in database 6 56
Import a excel sheet in a grid 2 45
EF5 How do I stop pre-compiled views? 8 57
Manage big list of parameter list 8 26
In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question