简体   繁体   中英

Search in Access Database table VB .Net

I have some problem to get data from table (ms-access databse) to show in my searchbox.text. The 'websiteTable' contains 14 columns (website name, website url, password, first name, gender ....and so on) I have this test code but it not find anything:

Private Sub btnSearch_Click(sender As Object, e As EventArgs) Handles btnSearch.Click
    DataGridView1.DataSource = Me.DataPwdDataSet.websiteTable.Select("Website Name like, Website Url like '" & SearchBox.Text & "'")
End Sub

The problem is I need search ALL Keywords from that selected table called 'websiteTable'; so when usr type in SearchBox.Text input any keyword it will display in DataGridView1.

Thank you guys!

If you use a BindingSource object it will be easier, faster and more safe way to filter the data. Then the filtering will be like this:

DataGridView1.DataSource = YourBindingsource
YourBindingSource.Filter = "Url like '" & TextBoxSerach.Text & "%'"

If you want read a little bit about binding Source .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM