title: inserting datetimepicker value to SQL Server 2008
body: <p>I'm trying to insert a value from a datetimepicker value to a SQL Server table.</p>
  
  <p>My table looks like this</p>
  
  <pre><code>Profile (Id, Name,..., DateofBirth(date)...)
  </code></pre>
  
  <p>I have tried this to convert datetime picker value to</p>
  
  <pre><code>string dt = dateTimePicker.Value.ToString("yyyy-mm-dd hh:MM:ss");
  
  Insert into profile (id, DateofBirth)  
  values(id,  CONVERT(datetime, CONVERT( varchar(11), dt, 101));
  </code></pre>
  
  <p>also use this</p>
  
  <pre><code>var date = new DateTime(dateTimePickerText);
  </code></pre>
  
  <p>also use this</p>
  
  <pre><code>DateTime date = DateBox.Value.Date;
  string sDate = date.ToString("dd-MM-yy", System.Globalization.CultureInfo.InvariantCulture);
  DateTime dateInsert = Convert.ToDateTime(sDate); 
  </code></pre>
  
  <p>but can't able to insert the date into the database. 2nd how can I retrieve back the date from database?</p>