title: Passing null into a SQL command
body: <p>I have a class:</p>
  
  <pre><code>public class Intlist
  {
      public int yesFlag{ get; set; }
      public int? noFlag { get; set; }
  }
  </code></pre>
  
  <p>I need to update a database table, but sometimes the value is null for the nullable ints. I am using</p>
  
  <pre><code>CommandText = @"UPDATE thetable 
                  SET Yes = " + list.yesFlag +
                     ",NoFlag = " + (list.previous == null) ? DBNull.Value : list.previous +
                     ",NextValue = 10" 
  </code></pre>
  
  <p>I'm trying to get it so that if noFlag is null, it enters a null in the database, but I'm getting errors:</p>
  
  <blockquote>
    <p>Cannot implicitly convert type 'string' to 'bool'</p>
  </blockquote>
  
  <p>and</p>
  
  <blockquote>
    <p>Type of conditional expression cannot be determined because there is
    no implicit conversion between 'System.DBNull' and 'string'</p>
  </blockquote>