vb.netvisual-studio-2010

filter name and username from datagridview using textbox


i am using combobox for option search name and username and textbox for filter there are error

missing operator

Error Image

        Try
            If Trim(TextBox1.Text) <> "" Then

                dataadapter1 = New OleDbDataAdapter("select * form login where " & ComboBox2.Text & " like '%" & Trim$(TextBox1.Text) & "%'", conn)

                datasetaccounts.Clear()
                dataadapter1.Fill(datasetaccounts, "login")

                DataGridView1.DataSource = datasetaccounts
                DataGridView1.DataMember = "login"
                DataGridView1.Refresh()
            End If
        Catch ex As Exception
            MsgBox("Error !: " + ex.Message)
        End Try

Solution

  • It should be:

    SELECT * FROM ...
    

    rather than:

    SELECT * FORM ...
    

    So nothing to do with filtering or ComboBoxes or DataGridViews or any of that. It's exactly what the error message told you: a syntax error in your SQL code.