Click here to Skip to main content
16,020,313 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hai ,i need advice and help here,In this programme i use 1 button( i name it btnsearch) and 1 textbox(i named it textboxname).The function of this button is use to search data in database and function of textbox is for user fill name.I want to put messagge box which if "Name is not found" in my code here.The reason is to inform to user that the name which their find in not in database.Any advice how i able to correct my code to solve this issue. Here is my code.I am using visual studio 2005 & sql 2005 as database .

VB
Private Sub Search_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsearch.Click
        Me.StaffBindingSource.Filter = "NAME =  '" & Me.txtsearch.Text & "'"

    End Sub
Posted
Updated 9-Sep-11 13:22pm
v2
Comments
Sergey Alexandrovich Kryukov 9-Sep-11 18:46pm    
Tag it! WPF, Forms, ASP.NET, what?!
--SA

1 solution

Something like this?

VB
dim prevFilter as string=Me.StaffBindingSource.Filter
Me.StaffBindingSource.Filter = "NAME =  '" & Me.txtsearch.Text & "'"

if Me.StaffBindingSource.count = 0 then
   msgbox ("Name is not found")
   'If the name is not found
   'Set the filter back to wath it was
   Me.StaffBindingSource.Filter= prevFilter
end if
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900