how to Filter datagridview using textbox from mysql database

  • Thread starter Thread starter no[one]
  • Start date Start date
N

no[one]

Guest
Please help me i have a problem here, i want to filter my datagridview

here is my sample data from mysql database

Id Name Date Remarks

1 Kenneth 27/11/2018 Finished

2 Jayson 27/11/2018 Unfinished


I filter my datagridview with this code and it only shows the data with "Unfinished" Remarks

Private Sub viewschedule_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim adapater As MySqlDataAdapter
Dim ds As New DataSet
Try
con.Open()
adapater = New MySqlDataAdapter("Select * from schedule ", con)
adapater.Fill(ds)
DataGridView1.DataSource = ds.Tables(0)
con.Close()
Catch ex As Exception
End Try

Dim dv As DataView
dv = New DataView(ds.Tables(0), "remarks = 'unfinished' ", "remarks", DataViewRowState.CurrentRows)
DataGridView1.DataSource = dv
End Sub


and i have a textbox for searching

Here is my code

Private Sub txtboxsearch_TextChanged(sender As Object, e As EventArgs) Handles txtboxsearch.TextChanged
Dim adapater As MySqlDataAdapter
Dim ds As New DataSet
Try
con.Open()
adapater = New MySqlDataAdapter("Select * from schedule where name Like '%" & txtboxsearch.Text & "%' ", con)
adapater.Fill(ds)
DataGridView1.DataSource = ds.Tables(0)
con.Close()
Catch ex As Exception
End Try

End Sub


But after searching a name in my textbox, it will show all the data in my database including the record with "finished" Remarks

Please help me how to do it i'm just a beginner

Continue reading...
 
Back
Top