This are my SQL columns: ItemID, ItemName, Unit, Quantity, UnitCost, Total, Status
ItemID is my barcode number and primary key. Quantity is an integer and has an identity increment value of 1.
If you call the same sql query twice, it doesn't allow you to duplicate a primary key.
What I want: If the query was called twice, then increase the Quantity value by 1, and double the UnitCost value, to be placed in the Total section.
My idea was that if it was a duplicate key, then just update it.
ON DUPLICATE KEY UPDATE SET
but I'm getting errors all over the place.
string sql = @"INSERT INTO Grocery (ItemID, ItemName, Unit, UnitCost, Total, Status) VALUES ('2414', '2414', 'EACH', '1.5', '1.5', 'LP') ON DUPLICATE KEY UPDATE ItemName='changed'";
connection.Open();
SqlCeCommand commandInsert = new SqlCeCommand(sql, connection);
commandInsert.ExecuteNonQuery();