title: String was not recognized as a valid datetime, source date is 0000-00-00 00:00:000
body: <p><strong>UPDATE</strong></p>
  
  <p>Apparently it was not caused by the <code>0000-00-00 00:00:000</code>, the program error out when the value was <code>2016-04-21 00:00:00.000</code> Any idea what could be the cause?</p>
  
  <hr/>
  
  <p>I have a VS C# program that will SELECT from MSSQL then INSERT/ON DUPLICATE UPDATE into MySQL database. I have a particular row which the datetime is <code>NULL</code>, my MSSQL query and result are:</p>
  
  <p><strong>Query</strong></p>
  
  <pre><code>SELECT UserID,LastPasswordDate,
  CASE WHEN LastPasswordDate IS NULL THEN '0000-00-00 00:00:00:000' 
      ELSE convert(varchar, LastPasswordDate, 121) END as LastPasswordDate2 from users
      order by LastPasswordDate
  </code></pre>
  
  <p><strong>Result</strong></p>
  
  <p><a href="https://i.stack.imgur.com/Bcta9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Bcta9.png" alt="enter image description here"></a></p>
  
  <p><strong>C# code</strong></p>
  
  <pre><code>string LastPasswordDate = row["LastPasswordDate"].ToString(); // Or
  //DateTime LastPasswordDate = DateTime.ParseExact(row["LastPasswordDate"].ToString(), "yyyy-MM-dd HH:mm:ss:fff", null);
  
  insertUserCommand.Parameters.AddWithValue("@LastPasswordDate", LastPasswordDate);
  insertUserCommand.ExecuteNonQuery();
  insertUserCommand.Parameters.Clear();
  tran.Commit();
  </code></pre>
  
  <p>I tried to use C# conversion but keep getting same error message as per title mentioned</p>