C# sql if query
本文关键字:query if sql | 更新日期: 2023-09-27 18:06:05
我试着做
var sql = String.Format("if ( {0} > (select sStrength from yCell where Cell_ID = '{1}')) begin UPDATE yCell SET sStrength = {0} WHERE Cell_ID = '{1}' end", inMaxStrength, inCellID);
SqlCeCommand myCommand = new SqlCeCommand(sql,connection);
myCommand.ExecuteNonQuery();
有一个错误:令牌行号= 1,令牌行偏移量= 1,令牌错误= if但是在sql studio中运行得很好
不能说为什么它失败了,但我可以建议你尝试在一个命令中更新:
UPDATE yCell SET sStrength = {0} WHERE Cell_ID = '{1}' AND {0} > sStrength