title: Update multiple rows in DataGridView C#
body: <pre><code>private void button1_Click(object sender, EventArgs e)
  {
      cn.Open();
      SqlCommand cmd = new SqlCommand("UPDATE MEDICINE_REGISTRATION SET stock = @RStock WHERE id= " + Order_Datagridview.SelectedRows[0].Cells["id"].Value.ToString() + "", cn);
  
      foreach (DataGridViewRow row in Order_Datagridview.Rows)
      {
  
          // cmd.Parameters.AddWithValue("@RStock", row.Cells["RStock"].Value);
  
          cmd.Parameters.Add("@RStock", SqlDbType.VarChar).Value = Order_Datagridview.SelectedRows[0].Cells["RStock"].Value.ToString();
          cmd.ExecuteNonQuery();
          MessageBox.Show("Success");
          cmd.Parameters.Clear();
  
      }
      cn.Close();
  }
  </code></pre>