I am trying to make a search box/ bar by using access Database. i want the code to search for the record and then then remove/hide the record from listbox when i search for another record. My programs belows searches for the Record and displays it, however there are few problems.
- does not remove/ hide the record when searching again.
- does not respond if the record isn't in database or if search box is empty.
Dim con As New OleDbConnection("Provider=Microsoft.jet.oledb.4.0;data source=C:\Users\jacob\Desktop\MS Office\project.mdb")
Dim cmd As OleDbCommand = New OleDbCommand("SELECT * FROM tblProduct WHERE productID LIKE '" & txtSearch_Bar.Text & "'", con)
con.Open()
Dim sdr As OleDbDataReader = cmd.ExecuteReader()
While (sdr.Read())
lstbSearchResult.Items.Add(sdr("ProductID"))
End While
i would also like to make this into a dynamic search bar.