title: SQL/VB.NET Search-Function looking for at least one correct input
body: <p>I'm writing a program in Visual Basic about Databases. Now I have a Sub/Function who searches the database for correct inputs. I have five text boxes where the user can put in something for each data field.</p>
  
  <pre><code>If txtBox1.Text &lt;&gt; "" Or txtBox2.Text &lt;&gt; "" Or txtBox3.Text &lt;&gt; "" Or txtBox4.Text &lt;&gt; "" Or txtBox5.Text &lt;&gt; "" Then
          Try
              connection.Open()
              command.CommandText = "SELECT * from lager WHERE (lager_waren_id LIKE '" &amp; txtBox1.Text &amp; "' OR lager_warenanzahl LIKE '" &amp; txtBox2.Text &amp; "' OR lager_warenname LIKE '%" &amp; txtBox3.Text &amp; "%' OR lager_warengewicht LIKE '" &amp; txtBox4.Text &amp; "%' OR lager_waren_verkaufspreis LIKE '" &amp; txtBox5.Text &amp; "%');"
              reader = command.ExecuteReader()
  
              FormKunde.Enabled = True
              FormKunde.lstViewKundeStore.Items.Clear()
              Do While reader.Read()
                  Dim lstViewItem As New ListViewItem(reader("lager_waren_id").ToString())
                  lstViewItem.SubItems.Add(reader("lager_warenanzahl").ToString())
                  lstViewItem.SubItems.Add(reader("lager_warenname").ToString())
                  lstViewItem.SubItems.Add(reader("lager_warengewicht").ToString())
                  lstViewItem.SubItems.Add(reader("lager_waren_verkaufspreis").ToString())
                  FormKunde.lstViewKundeStore.Items.Add(lstViewItem)
              Loop
              reader.Close()
              FormKunde.Enabled = False
          Catch ex As Exception
              MessageBox.Show(ex.Message)
          End Try
          connection.Close()
      Else
          MessageBox.Show("Please fill in something in the text fields")
          Exit Sub
      End If
  </code></pre>
  
  <p>I'm aksing the database if at least one text field has some input that matches to the data field it belongs to. But when I put something in, doesn't matter how much, nothing happens in my list view. It just loads all data back in the list view. When I try to do "AND" instead of "OR", it works only if i fill all text fields with the correct datas for one data set. But I want, that it finds all data sets.
  An example:
  I have two data sets where the names are "App" and "Apple". When i just fill in "Ap" in the field for names (nothing in the others) it shows me both. I think it should work with "OR", but it just does nothing.</p>
  
  <p>I'm really confused how to solve this, I hope anyone has a guess. Thank you!</p>