if (value > 0) { for(int i=0;i<mydatagrid.Rows.Count;i++) { SqlCommand cc = new SqlCommand("insert into store values(@sbno,@vno,@box,@qty,@pcs,@remark,@avail)", cn); cc.Parameters.AddWithValue("@sbno", sbno); cc.Parameters.AddWithValue("@vno", vno); cc.Parameters.AddWithValue("@box",Int32.Parse(dataGridView1.Rows[i].Cells[0].Value.ToString())); cc.Parameters.AddWithValue("@qty",Int32.Parse(dataGridView1.Rows[i].Cells[1].Value.ToString())); cc.Parameters.AddWithValue("@pcs",); cc.Parameters.AddWithValue("@remark",); cc.Parameters.AddWithValue("@avail", ); cc.ExecuteNonQuery(); } MessageBox.Show(nstdbox + " Boxes Stored To Store"); }
Set up the command Add the parameters -- do not use AddWithValue Iterate the rows Set the parameter values Execute the command
Int32.Parse(dataGridView1.Rows[i].Cells[0].Value.ToString())
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)