![]() |
| Figure 1.0 |
Step 2 >>>> double click your first textbox and paste this code and change it function to TextChanged;
str = "select * from info where Lname like %" & TextBox1.Text & "% and Fname like %" & TextBox2.Text & "%"
con.Open()
cmd = New MySqlCommand(str, con)
dr = cmd.ExecuteReader()
ListView1.Items.Clear()
Do While dr.Read()
Dim lv As ListViewItem = ListView1.Items.Add(dr.Item("Lname").ToString())
lv.SubItems.Add(dr.Item("Fname").ToString())
lv.SubItems.Add(dr.Item("Dept").ToString())
Loop
con.Close()
cmd.Dispose()
dr.Close()
Step 3 >>>> double click your second textbox and paste this code and change it function to TextChanged;
str = "select * from info where Lname like %" & TextBox1.Text & "% and Fname like %" & TextBox2.Text & "%"
con.Open()
cmd = New MySqlCommand(str, con)
dr = cmd.ExecuteReader()
ListView1.Items.Clear()
Do While dr.Read()
Dim lv As ListViewItem = ListView1.Items.Add(dr.Item("Lname").ToString())
lv.SubItems.Add(dr.Item("Fname").ToString())
lv.SubItems.Add(dr.Item("Dept").ToString())
Loop
con.Close()
cmd.Dispose()
dr.Close()
in this tutorial i use two Like filtering to make it easier to find the data that you want.
