i am entering one keyword in a textbox , and trying to retrieve that keyword matching columns from the backend.
the code i wrote for searching is as follows:
Dim i As Integer
Me.ListView1.Clear()
Dim ss As String = String.Format("select * from aaa where mqry1 like '%{0}%' or mqry2 like ' %{0}% '", Me.TextBox1.Text.Trim())
Dim da As New OleDbDataAdapter(ss, cn)
Dim table As New DataTable("aaa")
da.Fill(table)
Dim item As ListViewItem
Try
cn.Open()
For Each row As DataRow In table.Rows
item = New ListViewItem
If Not CStr(row("mqry1")).IndexOf(Me.TextBox1.Text.Trim()) = -1 Then
item.Text = CStr(row("mqry1"))
Me.ListView1.Items.Add(item)
Me.ListView1.View = View.List
End If
i = i + 1
Next
For Each row As DataRow In table.Rows
item = New ListViewItem
If Not CStr(row("mqry2")).IndexOf(Me.TextBox1.Text.Trim()) = -1 Then
item.Text = CStr(row("mqry2"))
Me.ListView1.Items.Add(item)
Me.ListView1.View = View.List
End If
i = i + 1
Next
catch x as exception
msgbox(x.message)
end try
cn.close()
my query is
my matching word contains in both "mqry1" and "mqry2" ,but only mqry1 is displayed
any modifications needed.
let me know ASAP.
thanks
the code i wrote for searching is as follows:
Dim i As Integer
Me.ListView1.Clear()
Dim ss As String = String.Format("select * from aaa where mqry1 like '%{0}%' or mqry2 like ' %{0}% '", Me.TextBox1.Text.Trim())
Dim da As New OleDbDataAdapter(ss, cn)
Dim table As New DataTable("aaa")
da.Fill(table)
Dim item As ListViewItem
Try
cn.Open()
For Each row As DataRow In table.Rows
item = New ListViewItem
If Not CStr(row("mqry1")).IndexOf(Me.TextBox1.Text.Trim()) = -1 Then
item.Text = CStr(row("mqry1"))
Me.ListView1.Items.Add(item)
Me.ListView1.View = View.List
End If
i = i + 1
Next
For Each row As DataRow In table.Rows
item = New ListViewItem
If Not CStr(row("mqry2")).IndexOf(Me.TextBox1.Text.Trim()) = -1 Then
item.Text = CStr(row("mqry2"))
Me.ListView1.Items.Add(item)
Me.ListView1.View = View.List
End If
i = i + 1
Next
catch x as exception
msgbox(x.message)
end try
cn.close()
my query is
my matching word contains in both "mqry1" and "mqry2" ,but only mqry1 is displayed
any modifications needed.
let me know ASAP.
thanks