title: Ignore empty textboxes while searching in database
body: <p>This code is able to search and load data to <code>DataGridView</code> based on values provided in search form text boxes. If I left any text box blank, there is no search result since the SQL query is combined with "AND". </p>
  
  <p>How can I ignore the empty textboxes while searching (from SQL query or C# code)?</p>
  
  <pre><code>private void btnSearch_Click(object sender, EventArgs e)
  {
      DataSet ds = new DataSet();
  
      String select = "SELECT DocumentNo, Revision, DocumentTitle, DocumentType
                       FROM DocumentLog
                       WHERE DocumentNo Like '%" + tbxDocumentNo.Text + "%'
                         AND Revision Like '%" + tbxRevision.Text + "%'
                         AND DocumentTitle Like '%" + tbxDocumentTitle.Text + "%'
                         AND DocumentType '%" + tbxDocumentType.Text + "%'"
                         AND IsDeleted = '0';
  
      SqlConnection conn = DBConnection.openConnection();
      SqlCommand command = new SqlCommand(select, conn);
  
      SqlDataAdapter da = new SqlDataAdapter(command);
      da.Fill(ds, "DocumentLog");
  
      dgvTracking.AutoGenerateColumns = false;
      dgvTracking.DataSource = ds.Tables["DocumentLog"];
  }
  </code></pre>