|
-
Oct 5th, 2011, 06:02 PM
#1
Thread Starter
New Member
[RESOLVED] Multiple Keyword Search in SQL Database
Hi all,
FIrstly, thanks for taking the time to read my post. I have been hunting the net for a couple of days now and have a problem I can not seem to resolve. I think in escence it is straight forward for a seasoned coder, I on the otherhand am still learning....
Put simply, I am trying to search one column (Titles) of an Access database using an SQL query. The search entry comes from a split string passed to an array and inserted into the SQL command.
This works well, however, the results I get back are for entries containing EITHER of the keywords entered, not entries containing ALL keywords entered.
The code I am using is::::
Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
dgvSearch.Visible = True
Dim GODSSearch As String = tbSearch.Text
If IsNumeric(GODSSearch) Then
ds.Tables("MyTable").DefaultView.RowFilter = "PageID =" & GODSSearch
Else
Dim mysearch As String = tbSearch.Text
Dim words() As String = mysearch.Split(" "c)
For Each word As String In words
ds.Tables("MyTable").DefaultView.RowFilter = "Title LIKE '%" & word & "%'"
Next
End If
End Sub
The loop is working, but acting as a new search as opposed to searching the results of the previous search.
I would personally kiss the feet of anyone who can assist me with this issue, I have about 4 remaining hairs on my head which are not likely to last the day!!
Thanks again
Ben
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|