title: How to insert datetime with milliseconds into Access database?
body: <p>I am trying to insert a date + time into an Access database using C#. The time string has milliseconds in it, e.g.:</p>
  
  <pre><code>"2015-03-23 11:22:33.123"`
  </code></pre>
  
  <p>Here is the code I have:</p>
  
  <pre><code>string strName = "somestring";
  string strDate = "2015-03-23 11:22:33.123"
  
  sql = @"insert into table_name  ([name], [date]) values (@Name, @Date)";
  
  using (OleDbCommand command = new OleDbCommand(sql))
  {
      command.Connection = openCon;
      command.Parameters.AddWithValue("@Name", strName);
      command.Parameters.AddWithValue("@Date", strDate ); // &lt;-- error here          
      openCon.Open();
      recordsAffected = command.ExecuteNonQuery();
      openCon.Close();
  }
  </code></pre>
  
  <p>I get an error at <code>ExcuteNonQuery()</code>; if I remove the date time string, then the code works. </p>
  
  <p>So how do I insert datetime with milliseconds into an Access database?</p>