本文介绍了更新查询未正确执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我做一个任务,我想要执行更新查询我的表名是Medicine_Available_Detail这里iam存储总药物可用列名是可用性,我有一个datagridview,其中我把药物的数量在用户输入特定药物的数量之后然后它表更新作为该药物的可用性 - 数量我写了代码但是没有执行
我的尝试:
int quantity = Convert.ToInt16(dataGridView1.Rows [e.RowIndex] .Cells [ Quantity跨度>]值)。
cmd = new OleDbCommand( @ update Medicine_Available_Detail set [可用性] = [可用性] - @ Quantity,其中Medicine_Name = @ Medicine_Name,con);
cmd.Parameters.AddWithValue( @ Quantity,quantity);
cmd.Parameters.AddWithValue( @ Medicine_Name,medicinename);
con.Open();
int n = cmd.ExecuteNonQuery();
con.Close();
MessageBox.Show( 记录成功更新);
解决方案
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 not executed
What I have tried:
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(); MessageBox.Show("Record Updated Successfully");
解决方案
这篇关于更新查询未正确执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!