title: insert more than one record from DataGridView
body: <p>This code works with the first row only
  and . I want this code  to work with the rest of the rows:</p>
  
  <pre><code>private void Save_Click(object sender, EventArgs e)
  {
      textBox1.Text =orderdetailsDataGridView.Rows.Count.ToString();
      try
      {
          using (SqlCommand cmd = new SqlCommand())
          {
              con.Open();
              cmd.Connection = con;
              cmd.CommandType = CommandType.StoredProcedure;
              cmd.CommandText = "OD1";
          foreach (DataGridViewRow row in orderdetailsDataGridView.Rows)
          {
              if (!row.IsNewRow)
              {
                  for (int x = 0; x &lt; orderdetailsDataGridView.Rows.Count; x++)
                  {
                      cmd.Parameters.Add("@order_id", SqlDbType.Int).Value = row.Cells[0].Value;
                      cmd.Parameters.Add("@prod_id", SqlDbType.Int).Value = row.Cells[1].Value;
                      cmd.Parameters.Add("@qun", SqlDbType.Int).Value = row.Cells[2].Value;
                      cmd.Parameters.Add("@price", SqlDbType.Decimal).Value = row.Cells[3].Value;
                      cmd.ExecuteNonQuery();
                      x++;
  
  
                  }
              }
          }
  
      }
  }
  catch (Exception er)
  {
      MessageBox.Show(er.ToString());
  }
  </code></pre>