如果我正确理解了您(我不确定我能做到),您需要这样的东西:
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 )注意我是如何使用参数而不是字符串连接的,非常重要!



