Searching error

ZziX

New member
Joined
May 5, 2012
Messages
1
Programming Experience
Beginner
Hey i've been having difficulty with my search button, it just retrieves the second row of data from the database. It is based by First Name, so if you type in a valid first name instead of bringing up that customers details for the desired person, it will bring who the details for the customer who has is 2nd in the database.
   Private Sub Src_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Src.Click
        Dim sqll = InputBox("First Name:", "Search", "John")
        Dim no As Integer
        Dim found As Boolean = False
        For no = 0 To len - 1
            If ds.Tables("Customertbl").Rows(no).Item(1).ToString.ToLower = sqll.ToString.ToLower Then
                i = no
                nav()
                found = True
            End If
        Next
        If (found = False) Then
            MsgBox("Search Not Found")
        End If
    End Sub



Thanks for any feedback, greatly appreciated!
 
I have add formatting tags to your code snippet. Please do so for us in future. As you can see, it's significantly easier to read.

If you are only interested in the first match then why do you keep searching after finding that first match? Once you find a match, if you don't want to keep searching then stop searching, i.e. exit out of the loop.
 
Back
Top