Dim Query As String = "Select * From car_t Where 1=1"
If String.IsNullOrWhiteSpace(Me.ComboBox1.Text) Then
MsgBox("Field is empty", MsgBoxStyle.Critical, "Error")
Me.ComboBox1.DroppedDown = True
Return
End If
If ComboBox1.SelectedIndex = 0 Then
If txtValue.Text <> "" Then
Query = Query & " AND car2 = '" & txtValue.Text & "'"
End If
End If
If ComboBox1.SelectedIndex = 1 Then
If txtValue.Text <> "" Then
Query = Query & " AND car3 = '" & txtValue.Text & "'"
End If
End If
If ComboBox1.SelectedIndex = 2 Then
If txtValue.Text <> "" Then
Query = Query & " AND car5 = '" & txtValue.Text & "'"
End If
End If
Dim cmd As New OleDbCommand(Query, con)
da = New OleDbDataAdapter(cmd)
ds.Clear()
da.Fill(ds, "car_t")
Me.DataGridView1.DataSource = ds