Search Any Value in ADO.NET
Private Sub notFound()
MsgBox("Record Not Found")
End Sub
Private Sub
Button7_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles
Button7.Click
If txtSearch.Text = ""
Then
StudentBindingSource.Filter = Nothing
Call notFound()
Exit Sub
Else
StudentBindingSource.Filter = "(Convert(ID,
'System.String') LIKE '" & txtSearch.Text & "')" & _
"OR (Sname LIKE '" & txtSearch.Text
& "')"
If StudentBindingSource.Count <> 0 Then
With DataGridView1
.DataSource = StudentBindingSource
'StudentBindingSource.Filter = Nothing
End With
Else
MsgBox("The search item was not found.")
StudentBindingSource.Filter = Nothing
End If
End If
End Sub
No comments:
Post a Comment