Searching in datagridview with database access Visual Studio

39 views Asked by At

Good Day! I'm clueless on visual studio. Please Help me. I have a datagridview that has database access file. its bound to textboxes

now i have a search button that has a textbox too. it runs fine but it needs to input the complete name. I want it to be when you just input a letter it shows all the names that has/have that letter. for example if i type "A" all names in the the database that has letter "A" on it will show.

but in this case if i type "AGING" it will say cant find. It must be "AGING OVEN" for it to show the result. here is my code. please help thanks

Private Sub SearchBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SearchBtn.Click
    On Error GoTo SearchErr

    If SearchTxtbox.Text = "" Then
        Exit Sub
    Else
        Dim cantFind As String = SearchTxtbox.Text

        TOOLSANDEQUIPMENTBindingSource.Filter = "(CONVERT(ID, 'System.String') like '" & SearchTxtbox.Text & "')" & _
            "OR ([TOOL and EQUIPMENT] like '" & SearchTxtbox.Text & "') OR ([QUANTITY] like '" & SearchTxtbox.Text & "')" & _
          "OR ([ITEM NO] like '" & SearchTxtbox.Text & "')" & _
          "OR ([PART NO] like '" & SearchTxtbox.Text & "')" & _
          "OR ([DATE MODIFIED] like '" & SearchTxtbox.Text & "')"

        If TOOLSANDEQUIPMENTBindingSource.Count <> 0 Then
            With TEDataGridView
                .DataSource = TOOLSANDEQUIPMENTBindingSource
            End With

        Else


            MsgBox("--> " & cantFind & vbNewLine & _
                   "The search item was not found.", _
                   MsgBoxStyle.Information, "Hey Boss!")
            TOOLSANDEQUIPMENTBindingSource.Filter = Nothing

            With TEDataGridView
                .ClearSelection()
                .ReadOnly = True
                .MultiSelect = False
                .DataSource = TOOLSANDEQUIPMENTBindingSource
            End With
        End If
    End If
ErrEx:
    Exit Sub
SearchErr:
    MsgBox("Error Number " & Err.Number & vbNewLine & _
           "Error Description " & Err.Description, MsgBoxStyle.Critical, _
           "Reser Error!")
    Resume ErrEx

End Sub
0

There are 0 answers