如何使用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"