-1

我试着做

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中它运行正常。

4

1 回答 1

1

不能说为什么会失败,但我可以建议您尝试在一个命令中更新:

UPDATE yCell SET sStrength = {0} WHERE Cell_ID = '{1}' AND {0} > sStrength

于 2013-03-26T23:10:24.620 回答