shyam kumar

shyam kumar

  • NA
  • 8
  • 689

INSERT QTY IN DATABASE 1 BY 1 PCS

Feb 21 2018 7:19 AM
//purchaseitem barcode
for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
string stck = "INSERT INTO stock (isissue)" + "VALUES (@quantity)";
cmd = new OleDbCommand(stck, con);
cmd.Parameters.AddWithValue("quantity", dataGridView1.Rows[i].Cells[9].Value.ToString());
for (int q = 0; q <= int.Parse(dataGridView1.Rows[0].Cells[9].Value.ToString()); q++)
try
{
con.Open();

cmd.ExecuteNonQuery();
{
clear();
}
MessageBox.Show("Saved Successfully");
con.Close();

}
catch (Exception X)
{
MessageBox.Show(this, "Error" + X, "Stop", MessageBoxButtons.OK, MessageBoxIcon.Stop);
}
}
}
 
 
( I HAVE TRIED THIS CODE IN C# BUT THIS CODE INSERT THE DATA BY QTY CELL VALUE
LIKE QTY CELL VALUE = 5 , THEN THIS CODE INSERT THE DATA 5 VALUE 5 TIMES
I WANT CODE TO INSERT DATA 1 VALUE  TO 5 TIMES TO CREATE BARCODE
 

Answers (2)