Click here to Skip to main content
15,895,799 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i use Database ms Access, and i try to Update some Rows with use parameters like code below
C#
 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 hope is that the data is updated in accordance with the parameters, but instead all data is updated.
what wrong?
Posted
Comments
[no name] 23-Aug-15 8:02am    
Please check what is the value is passing in label1.Text
If it is blank/0 and your database NoRef column value is blank then it will update all records.
Member 11057420 23-Aug-15 8:12am    
ok thx, this solved, im wrong :-), the NoRef should RefNo

1 solution

Answered only to remove from unanswered list: solved by OP.
"ok thx, this solved, im wrong :-), the NoRef should RefNo"
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900