title: Insert DateTime into Sql Server 2008 from C#
body: <p>I've been trying to get this right for over 2hrs so any help is highly appreciated</p>
  
  <pre><code>  public void setAppointment(int studentID, DateTime appt)
      {
          connection.Open();
  
          string sqlStatement3 = "UPDATE dbo.students SET appointmentDate = '" + appt.Date.ToString("yyyy-MM-dd HH:mm:ss") + "' WHERE ID = " + studentID + ";";
  
          OleDbCommand updateCommand = new OleDbCommand(sqlStatement3, connection);            
          updateCommand.ExecuteNonQuery();
  
          connection.Close();
      }
  </code></pre>
  
  <p>So basically what that does is insert a datetime into an sql server table keeping the same format of the month and day to avoid regional settings getting in the way.</p>
  
  <p>The only problem is that the time remains 00:00:00. Even though when I debug the code, 'appt' shows 28/06/2013 09:30:00</p>