title: The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value
body: <p>I have a WPF application. <code>date</code> is my table and its two columns are <code>employeename</code> (<code>varchar(10)</code>)  and <code>date</code> (<code>datetime</code>)</p>
  
  <p>My code is:</p>
  
  <pre><code>Sqlconncetion con = new Sqlconnection("my database connection ");    
  SqlCommand cmd = new SqlCommand("insert into date values('"+textBox1.Text+"','"+datePicker1.Text+"')", con);    
  con.Open();               
  int n = cmd.ExecuteNonQuery();                
  if (n &gt; 0)
  {
      MessageBox.Show("insert");
  }
  </code></pre>
  
  <p>Actually my WPF <code>datepicker</code> formats inputs as <code>"dd/mm/yyyy</code>" and SQL Server table accept date format <code>mm/dd/yyyy</code>. How can I change my SQL Server <code>datetime</code> datatype date format? please give solution by code in c#..</p>
  
  <p>My task is to display all name and birth date. My condition is basic but at time of date selection and button enter, I get exception. My code is</p>
  
  <pre><code>SqlConnection con = new SqlConnection("my connection ");
  
  SqlDataAdapter da = new SqlDataAdapter("select name,date from date where date between'"+ Convert.ToDateTime( datePicker2.SelectedDate)+"' and  '"+ Convert.ToDateTime( datePicker3.SelectedDate)+"'",con);
  
  DataSet ds = new DataSet();
  
  da.Fill(ds, "entry");
  
  da.Dispose();
  
  dataGrid1.DataContext = ds.Tables["entry"].DefaultView; 
  </code></pre>
  
  <p>plz help me solve code error and write correct code . this is a WPF application.</p>