I have a simple query updating the ProductPrice
column by replacing old data and updating ProductQuantity
which is being added to the previous one.
I wrote the query in SQL and it's working fine, but in the VS code it's concatenating the ProductQuantity
. Like if I have 20
in product quantity then after this the result should be 20 + 50 = 70
but after executing query in code it updates the value to 2050
The query in SQL is:
UPDATE ProductLog
SET ProductQuantity = ProductQuantity + 50,
ProductPrice = 20
WHERE ProductCode = 1
The query in my C# code is:
sql = "";
sql += "UPDATE ProductLog
SET ProductQuantity = ProductQuantity
+ '"
+ productQuantity
+ "', ProductPrice = '"
+ productPrice
+ "' WHERE ProductCode = '"
+ ProductCode
+ "'";
I am not able to find my mistake in code query. Please guide me in this regard.
The column's datatype in the table is varchar
.