title: How to move data from listview and insert into database?
body: <p>in my litte project, I have two listview and two db. First listview is fill from the first database table. the second is fill from the first selected item.</p>
  
  <p>The two listboxes are built in same mode: </p>
  
  <pre><code>`name | surname | id`.
  </code></pre>
  
  <p>In the first listbox I have the list of all the users insert in the db</p>
  
  <pre><code>`Ale | Zucchelli | 5`
  `Faby | Jake | 6`
  `Alexa | Doctor | 7`
  `Mattias | Rossi | 12`
  </code></pre>
  
  <p>When I select an element an click on the move button, the select item move to the second listbox.</p>
  
  <pre><code> second listbox items
  
  `Ale | Zucchelli | 5`
  `Mattias | Rossi | 12`
  </code></pre>
  
  <p>When I click on Insert button, the items of the second listbox I must send it to second table of my db, but I must to register only the the id. </p>
  
  <p>I have try this code:</p>
  
  <p>private void btmconferma_Click(object sender, EventArgs e)
      {</p>
  
  <pre><code>    string idutente;
      //string idu_retrive = string.Empty;
      //object value = 0;
      idutente = user.Text;
  
      //string querysql2 = " INSERT INTO AMICIZIA (IdUtente1, [idamici]) VALUES ('" + idutente + "', '" + value + "')";
      //SqlConnection myconn = new SqlConnection(CnnStr);
      //SqlCommand mycmd = new SqlCommand(querysql2, myconn);
      foreach (ListViewItem l in listamicizie.Items)
      {
          string CnnStr = System.Configuration.ConfigurationSettings.AppSettings["CnnStr"].ToString();
          SqlConnection myconn = new SqlConnection(CnnStr);
          myconn.Open();
          SqlCommand cmd = new SqlCommand("insert into AMICIZIA (IdUtente1) values('" + idutente + "')", myconn);
          //SqlCommand cmd1 = new SqlCommand("insert into AMICIZIA (idamici) values('" + l.SubItems["IdUtente"].ToString() + "')", myconn);
          SqlCommand cmd1 = new SqlCommand("insert into AMICIZIA (idamici) values('" + listamicizie.Columns["IdUtente"].Text + "')", myconn);
  
  
          cmd.ExecuteNonQuery();
          cmd1.ExecuteNonQuery();
          myconn.Close();
      }
  
  
      this.Close();
  }
  </code></pre>
  
  <p>The value of IdUtente is right, but the value of idamici is always zero.
  How that i do?</p>