title: The conversion of a varchar data type to a datetime data type resulted in an out-of-range value in asp.net
body: <p>I have a column of data type <code>datetime</code> in my table and I would like to insert a date value from a text box into the table but I am getting this error:</p>
  
  <blockquote>
    <p>The conversion of a varchar data type to a datetime data type resulted in an out-of-range value</p>
  </blockquote>
  
  <p>Here is my code:</p>
  
  <pre><code>string prfer_date = txtDT_Particip.Text;
  int userId = 0;
  string constr = ConfigurationManager.ConnectionStrings["mycon"].ConnectionString;
  
  using (SqlConnection con = new SqlConnection(constr))
  {
      using (SqlCommand cmd = new SqlCommand("Insert_User"))
      {
          using (SqlDataAdapter sda = new SqlDataAdapter())
          {
              cmd.CommandType = CommandType.StoredProcedure;
              cmd.Parameters.AddWithValue("@FullName", txtFName.Text.Trim());
              cmd.Parameters.AddWithValue("@PreferredDateStart", prfer_date.ToString());
          }
       }
   }
  </code></pre>
  
  <p>it is failing at <code>prfer_date</code>. Thanks for your help</p>