i tried below code.but i could add one row record only added in to mysql database. i entered three rows records but only one row records only added.what is the problem of the below code please any one can help me this problem.
for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
MySqlCommand cmd = new MySqlCommand();
cmd.Connection = con;
cmd.CommandText = "insert into salesproductnew(salesid,productname,qty,price,grosstotal)values(@salesid,@productname,@qty,@price,@grosstotal)";
cmd.Parameters.AddWithValue("@salesid", lbinvoice.Text);
cmd.Parameters.AddWithValue("@productname", dataGridView1.Rows[i].Cells[2].Value);
cmd.Parameters.AddWithValue("@qty", dataGridView1.Rows[i].Cells[3].Value);
cmd.Parameters.AddWithValue("@price", dataGridView1.Rows[i].Cells[4].Value);
cmd.Parameters.AddWithValue("@grosstotal", dataGridView1.Rows[i].Cells[5].Value);
con.Open(); cmd.ExecuteNonQuery();
MessageBox.Show("Record added ............."); con.Close();
Bidyasagar MishraPosted May 19, 2017, 9:35 AM
Rafnas T PPosted May 4, 2017, 7:58 AM
Kobinath RamPosted May 4, 2017, 7:55 AM
Rafnas T PPosted May 4, 2017, 7:31 AM
Amit GuptaPosted May 4, 2017, 6:02 AM
Kobinath RamPosted May 4, 2017, 5:55 AM
Karthi KeyanPosted May 4, 2017, 2:21 AM
Rafnas T PPosted May 4, 2017, 1:19 AM
Kobinath RamPosted May 4, 2017, 1:09 AM
Rafnas T PPosted May 4, 2017, 12:24 AM
Kobinath RamPosted May 4, 2017, 12:21 AM
Karthi KeyanPosted May 4, 2017, 12:08 AM
Kobinath RamPosted May 4, 2017, 12:02 AM
Rafnas T PPosted May 3, 2017, 11:37 PM
Amit GuptaPosted May 3, 2017, 1:44 PM
Khaja MoizuddinPosted May 3, 2017, 1:34 PM
Kobinath RamPosted May 3, 2017, 1:33 PM
Amit GuptaPosted May 3, 2017, 11:57 AM