Solved

VB.net Filter a column by a certain value

Posted on 2013-01-14
2
292 Views
Last Modified: 2013-01-14
Hi. I am using the following code to Load a DataGridView with data from an SQL table.
I have a text box (TextBox1) that the user types a Supplier Name  in. What code would I use to Filter the DataGridView to show anything where the SupplierName column is similar in the DataGridView


    Public oAdapter_SQL As SqlDataAdapter
    Public oDataTable_SQL As New DataTable

    Private Sub oLoad
        Try
            'Clear the data table
            Me.DataGridView1.DataSource = Nothing
            Dim sSQL As String
            Dim oConnectionString As String = Globals.ThisAddIn.oRIGHT.lblConnectionString.Text

            sSQL = "Select * From Transactions"

                oDataTable_SQL.Clear()
                Dim connection As New SqlConnection(oConnectionString)
                oAdapter_SQL = New SqlDataAdapter(sSQL, connection)
                oAdapter_SQL.Fill(oDataTable_SQL)
                Me.DataGridView1.DataSource = oDataTable_SQL

        Catch ex As Exception
            MsgBox(ex.Message & " 202")
        End Try
    End Sub
0
Comment
Question by:murbro
2 Comments
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 38775928
Something like below should work

button_click:

oDataTable_SQL.DefaultView.RowFilter = "SupplierName Like %' & txtSearch.Text & "%'"
Me.DataGridView1.DataSource = oDataTable_SQL.DefaultView
0
 

Author Closing Comment

by:murbro
ID: 38775973
Thanks very much
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Get Top Visible Row of Datagridview 6 32
Exit the loop 4 42
VB.NET 2008 (3.5 Framework) Remove all items from List 3 21
get column names from table in vb.net 8 25
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

816 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now