title: C# sql if query
body: <p>I try to do</p>
  
  <pre><code>var sql = String.Format("if ( {0} &gt; (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();
  </code></pre>
  
  <p>there is an error: Token line number = 1,Token line offset = 1,Token in error = if 
  But in sql studio it runs fine.</p>