plz give solution for the problem with with following code written in a button.
the purpose is updating the database table with the contents of each row in the datagridview control.
the problem is only one row is getting updated in database table even i updated many rows.
con = new SqlConnection(str);
con.Open();
foreach (DataGridViewRow row in dataGridView1.Rows)
{
cmd = new SqlCommand("UPDATE scan_rmfb_temp SET product = @prod Where id = '" + dataGridiview1.CurrentRow.Cells[0].Value.ToString() + "' ", con);
cmd.Parameters.AddWithValue("@prod",dataGridView1.CurrentRow.Cells[5].Value.ToString());
cmd.ExecuteNonQuery();
}
thanks and regards
madhu
the purpose is updating the database table with the contents of each row in the datagridview control.
the problem is only one row is getting updated in database table even i updated many rows.
con = new SqlConnection(str);
con.Open();
foreach (DataGridViewRow row in dataGridView1.Rows)
{
cmd = new SqlCommand("UPDATE scan_rmfb_temp SET product = @prod Where id = '" + dataGridiview1.CurrentRow.Cells[0].Value.ToString() + "' ", con);
cmd.Parameters.AddWithValue("@prod",dataGridView1.CurrentRow.Cells[5].Value.ToString());
cmd.ExecuteNonQuery();
}
thanks and regards
madhu