title: How to insert new added rows of data from datagridview into database?
body: <p>I have a datagridview, and some data in the table.
  The datagridview allows users to enter new rows of data</p>
  
  <p>Question here:</p>
  
  <p>I would like to know how can I get the new inserted rows of data(no matter how many rows have been added) into database without adding the existing data which will then be duplicated.</p>
  
  <p>Anyone?</p>
  
  <p>EDIT: im using sql database, and this is my datagridview.</p>
  
  <p><img src="https://i.stack.imgur.com/4Yz1z.jpg" alt="enter image description here"></p>
  
  <p>the data shown is already inside database, now, what if users insert NEW MULTIPLE rows of data into the datagridview? what is the code should I put?</p>
  
  <p>My code as below :</p>
  
  <pre><code>private void button1_Click(object sender, EventArgs e)
          {
              con = new System.Data.SqlClient.SqlConnection();
              con.ConnectionString = "Data Source=tcp:SHEN-PC,49172\\SQLEXPRESS;Initial Catalog=LSEStock;Integrated Security=True";
              con.Open();
              SqlDataAdapter da = new SqlDataAdapter();
  
              for (int i = 0; i&lt;dataGridView1.Rows.Count; i++ )
              {
  
                  String insertData = "INSERT INTO CostList(SupplierName, CostPrice, PartsID) VALUES (@SupplierName, @CostPrice, @PartsID)" ;
                  SqlCommand cmd = new SqlCommand(insertData, con);
                  cmd.Parameters.AddWithValue("@SupplierName", dataGridView1.Rows[i].Cells[0].Value);
                  cmd.Parameters.AddWithValue("@CostPrice", dataGridView1.Rows[i].Cells[1].Value);
                  cmd.Parameters.AddWithValue("@PartsID", textBox1.Text);
                  da.InsertCommand = cmd;
                  cmd.ExecuteNonQuery();
              }
  
              con.Close();
  </code></pre>