title: How to pass in nullable INT type to INSERT INTO parameter
body: <p>I need to pass in a nullable int type (passed in as an OPTIONAL param, sometimes it's defined, sometimes it's not...) into an INSERT INTO command in C# via paramters.  Below is a screenshot of my code.</p>
  
  <p>Here is the offending line of code, truncated for clarity...</p>
  
  <pre><code>public void WriteCustomColumns(... int? parentPlacementId = null)
  {
      command.Parameters["@ParentPlacementId"].Value = (parentPlacementId == null ? System.Data.SqlTypes.SqlInt32.Null.Value : parentPlacementId);
  </code></pre>
  
  <p><strong>Here is the screenshot of the error...</strong></p>
  
  <p><img src="https://i.stack.imgur.com/4jfKS.png" alt="screenshot"></p>