MySQL VB.NET Tutorial 14 : Search data in database and Filter in datagridview




Code for searching data from database using Visual Basic Visual Basic Search in database VB.NET how to search data in database in asp.net with Visual Basic …

Original source


29 responses to “MySQL VB.NET Tutorial 14 : Search data in database and Filter in datagridview”

  1. I Have Followed all the ways to fix cannot find column
    this is my code :
    Dim DV As New DataView(dbDataSet)
    DV.RowFilter = String.Format("[Name of Driver] Like '%" & MetroTextBox1.Text & "%'")
    MetroGrid1.DataSource = DV

    and i also remove the
    Dim dbDataSet As New DataTable
    In the load sub
    but it always some me this error
    What should i do?

  2. If you want to put it in a button here is the code 🙂 (VISUAL STUDIO 2013)
    copied the loaddata() and edi the sql/query

    Private Sub btnSearch_Click(sender As Object, e As EventArgs) Handles btnSearch.Click

    mysqlconn = New MySqlConnection
    mysqlconn.ConnectionString = "server=localhost;userid=root;password=;database=dbdata"

    Dim dtAdapter As New MySqlDataAdapter
    Dim dt As New DataTable
    Dim bsource As New BindingSource

    Try
    mysqlconn.Open()
    Dim sql As String
    sql = "SELECT * FROM dbdata.edata WHERE ename LIKE '%" + txtSearch.Text + "%' "
    cmd = New MySqlCommand(sql, mysqlconn)

    dtAdapter.SelectCommand = cmd
    dtAdapter.Fill(dt)
    bsource.DataSource = dt
    DataGridView1.DataSource = bsource
    dtAdapter.Update(dt)

    mysqlconn.Close()

    Catch ex As MySqlException
    MessageBox.Show(ex.Message)
    Finally
    mysqlconn.Dispose()
    End Try
    End Sub

  3. My one doesn't work. I will begin typing a search and then the values in the data grid view will disappear and it will show just the grey background and stay like that until I close the whole program. Help please!

  4. Seems there isn't much feedback coming from the owner of this Tutorial. If you need help here, I will do my best, just ask.

    I have automated this to load any table from any database using a combobox. It is working like a dream come true. Thanks for the tutorial. This is going to make me lots of money.

  5. After following step by step your tutorials, kind sir, I have encountered a rather uncanny error. It appears that, after deleting the line "Dim dbDataSet As New DataTable" and declaring it as a global variable, if you press the "Load Table" button, it stores the table multiple times. I do not know for sure if this is the main issue, but after copying the line back to it's original place, everything seems to work out pretty good 🙂 Thank you for those helpfull tutorials, once again and don't take my commentary as a malitious one, please. Just wanted to point out a possible error 🙂 Have a nice day!

Leave a Reply