title: How can I remove previous result of search from listview using C# and SQL
body: <p>I want to remove the previous result from <code>ListView</code> because the first result is fine but the second is duplicate the result. How can I solve this problem?</p>
  
  <pre><code>private void btn_search(object sender, DataGridViewCellEventArgs e)
  {
      SqlConnection con = new SqlConnection(@"Server=.\SQLEXPRESS; Database=Student; Integrated Security=true");
      SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM info WHERE id LIKE '" + box4.Text + "%'", con);
  
      DataTable dt = new DataTable();
      da.Fill(dt);
  
      foreach (DataRow row in dt.Rows)
      {
          ListViewItem item = new ListViewItem(row[0].ToString());
  
          for (int i = 1; i &lt; dt.Columns.Count; i++)
          {
              item.SubItems.Add(row[i].ToString());
          }
  
          listView1.Items.Add(item);
      }
  }
  </code></pre>
  
  <hr>
  
  <p>Update based on comments:</p>
  
  <pre><code>private void btn4_Click_1(object sender, EventArgs e)
  {
      listView1.Items.Clear();
  
      SqlConnection con = new SqlConnection(@"Server=.\SQLEXPRESS; Database=Student; Integrated Security=true");
      SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM info WHERE id LIKE '" + box4.Text + "%'", con);
  
      DataTable dt = new DataTable();
      da.Fill(dt);
  
      listView1.Items.Clear();
  
      foreach (DataRow row in dt.Rows)
      {
          ListViewItem item = new ListViewItem(row[0].ToString());
  
          for (int i = 1; i &lt; dt.Columns.Count; i++)
          {
              item.SubItems.Add(row[i].ToString());
          }
  
          listView1.Items.Add(item);
      }
  }
  </code></pre>