Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Help with filtering data from DataTable

Posted on 2014-02-17
4
Medium Priority
?
226 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
  • 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 2000 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

972 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