I have a textbox for searching in my access database. For example, my database is dbEmpLis; my table name is tblEmployee; columns in my tblEmployee are fName, lName and mName. What I want to do is,when a user type to the search box, and click the search button, it will search to the database.Then if it find any match within the database it will return the value/s to the listbox.

Recommended Answers

All 2 Replies

khentz,
I'm curious which are you wanting to fill ListView or ListBox? You're title say one and your question says another.

Ken

Hi

Declare a new DataSet, then execute a standard query to populate the DataSet.

Dim sqlString As String = ("SELECT tblEmployee.fName, tblEmployee.lName, tblEmployee.mName FROM tblEmployee WHERE tblEmployee.fName LIKE '%" & txtSearch.Text & "%'")

txtSearch.Text is an textbox on the form.

Go into a "for each" loop and place it into a list/grid-view.

Hope this helps.

Try reading up on queries if your going to be working with databases..

http://www.w3schools.com/sql/default.asp

This would be an excellent place to start.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.