title: Pass a NULL in a parameter to a DateTime field in a stored procedure
body: <p>I have a stored procedure which updates a database using the parameters I supply but I'm having trouble passing a NULL to the stored procedure</p>
  
  <p>The field I need to make NULL is a DateTime field</p>
  
  <pre><code>DB.Parameters.AddWithValue("@date", NULL)
  </code></pre>
  
  <p>This gives me the error </p>
  
  <blockquote>
    <p>'NULL' is not declared. 'Null' constant is no longer supported; use 'System.DBNull' instead</p>
  </blockquote>
  
  <p>So I tried </p>
  
  <pre><code>DB.Parameters.AddWithValue("@date", DBNull.Value.ToString())
  </code></pre>
  
  <p>But this produces the value <code>1900-01-01 00:00:00.000</code> in the column as it's passing a <code>""</code> to the field</p>
  
  <p>I also tried </p>
  
  <pre><code>DB.Parameters.AddWithValue("@date", DBNull.Value)
  </code></pre>
  
  <p>But it produces this error</p>
  
  <blockquote>
    <p>Value of type 'System.DBNull' cannot be converted to 'String'.</p>
  </blockquote>
  
  <p>Has anybody got any ideas?</p>