如何使用C#中的参数更新数据库ms访问中的行数据 [英] How To Update Rows Data in Database ms Access With Parameter in C#
本文介绍了如何使用C#中的参数更新数据库ms访问中的行数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用Database ms Access,我尝试使用下面的代码使用参数更新一些行
i use Database ms Access, and i try to Update some Rows with use parameters like code below
OleDbCommand cmdEditOffline = new OleDbCommand();
cmdEditOffline.CommandText = "UPDATE TbTransactionToOffline SET Amount = @Amount WHERE NoRef = @NoRef";
cmdEditOffline.Connection = conn;
cmdEditOffline.Parameters.Add("@Amount", OleDbType.VarChar).Value = txtAmount.Text;
cmdEditOffline.Parameters.Add("@NoRef", OleDbType.VarChar).Value = label1.Text;
if (conn.State == ConnectionState.Closed) conn.Open();
cmdEditOffline.ExecuteNonQuery();
this.Close();
i希望是那个数据是根据参数更新的,而是更新了所有数据。
有什么问题?
i hope is that the data is updated in accordance with the parameters, but instead all data is updated.
what wrong?
推荐答案
只回复未答复的清单:由OP解决。
好的,这解决了,我错了:-),NoRef应该RefNo
Answered only to remove from unanswered list: solved by OP.
"ok thx, this solved, im wrong :-), the NoRef should RefNo"
这篇关于如何使用C#中的参数更新数据库ms访问中的行数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文