foreach (DataGridViewRow row in dataGridView1.Rows)
{
if (row.Cells[0].Value == null && row.Cells[1].Value == null && row.Cells[2].Value == null && row.Cells[3].Value == null && row.Cells[4].Value == null && row.Cells[5].Value == null && row.Cells[6].Value == null && row.Cells[7].Value == null)
{
}
else
{
con.Open();
OleDbCommand cmd = new OleDbCommand("insert into Sold(Product_name,Model_no,Seater,Leather,Colour,Unit_price,Quantity,Total,Advancepayment,Duespayment) values (@Product_name,@Model_no,@Seater,@Leather,@Colour,@Unit_price,@Quantity,@Total,@Advancepayment,@Duespayment)", con);
cmd.Parameters.AddWithValue("@Product_name", row.Cells[0].Value.ToString());
cmd.Parameters.AddWithValue("@Model_no", row.Cells[1].Value.ToString());
cmd.Parameters.AddWithValue("@Seater", row.Cells[2].Value.ToString());
cmd.Parameters.AddWithValue("@Leather", row.Cells[3].Value.ToString());
cmd.Parameters.AddWithValue("@Colour", row.Cells[4].Value.ToString());
cmd.Parameters.AddWithValue("@unit_price", row.Cells[5].Value.ToString());
cmd.Parameters.AddWithValue("@Quantity", row.Cells[6].Value.ToString());
cmd.Parameters.AddWithValue("@Total", row.Cells[7].Value.ToString());
cmd.Parameters.AddWithValue("@Advancepayment", textBox4.Text);
cmd.Parameters.AddWithValue("@Duespayment", label35.Text);
cmd.ExecuteNonQuery();
}
}
i don't know dear without looping so....