I need to perform an update in a table(Homework). But it is not just replacing an old value with a new one; to the already existing value in the column i have to add(SUM) th
If i understand you correctly (i'm not sure i do) you want something like this:
string sql2 = "UPDATE student SET moneyspent = moneyspent + @spent WHERE id=@id";
SqlCommand myCommand2 = new SqlCommand(sql2, conn);
myCommand2.Parameters.AddWithValue("@spent", 50 )
myCommand2.Parameters.AddWithValue("@id", 1 )
Notice how i've used parameters and not string concatenation, very important!!