Hi all,
Iam doing one task where i want to executed update query i have table name is Medicine_Available_Detail here iam storing total medicine available column name is Availability,I have one datagridview where im putting Quantity of that Medicine after user enter Quantity of particular medicine then it table update as Availability-Quantity for that medicine i written a code but its executed but record not updated
private void dataGridView1_RowLeave(object sender, DataGridViewCellEventArgs e)
{
int quantity = Convert.ToInt16(dataGridView1.Rows[e.RowIndex].Cells["Quantity"].Value);
cmd = new OleDbCommand("update Medicine_Available_Detail set [Availability]=[Availability]-@Quantity where [Medicine_Name]=@Medicine_Name", con);
cmd.Parameters.AddWithValue("@Quantity", quantity);
cmd.Parameters.AddWithValue("@Medicine_Name", medicinename);
con.Open();
int n = cmd.ExecuteNonQuery();
con.Close();
} 4 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Bryian TanPosted Feb 16, 2017, 2:43 PM
Amit GuptaPosted Feb 16, 2017, 1:51 PM
Atul RokadePosted Feb 16, 2017, 1:51 PM
Bryian TanPosted Feb 16, 2017, 1:42 PM