title: How to get saved date value from Sql Server in dateTimePicker Control in Windows Application
body: <p>I have a simple registration table of employee having column Name, Number, Email, DOB, JoinDate.
  I want to populate this value in the form in respective controls, i.e Name value goes in textbox and DOB value goes in dateTimePicker control and dateTimePicker automatically select the date which is coming from DB.
  I do the logics for textboxes but not have a solution for dateTimePicker Control.
  I am attaching some code for reference. </p>
  
  <pre><code>using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["DBCN"].ConnectionString))
  {
  
              SqlCommand cmd = new SqlCommand("Select * from EmpRegister", con);
              con.Open();
  
              SqlDataAdapter da = new SqlDataAdapter();
  
              DataTable dt = new DataTable();
              da.SelectCommand = cmd;
              da.Fill(dt);
              if (dt != null &amp;&amp; dt.Rows.Count &gt; 0)
              {
  
  
                  txtName.Text = dt.Rows[0]["EmpName"].ToString();
                  txtPassword.Text = dt.Rows[0]["Password"].ToString();
                  txtPassword.Enabled = false;
                  txtUserName.Text = dt.Rows[0]["UserName"].ToString();
  
                  txtDesignation.Text = dt.Rows[0]["EmpDesignation"].ToString();
                  txtMobileNumber.Text = dt.Rows[0]["Empnumber"].ToString();
                  txtEmailId.Text = dt.Rows[0]["EmpEmail"].ToString();
                  bindRole();
                  comboboxRole.SelectedValue = dt.Rows[0]["EmpRole"].ToString();
  
                  dateTimePickerJoinDate.Value = Convert.ToDateTime("JoinDate");
  
                  dateTimePickerDOB.Value = dt.Rows[0][Convert.ToDateTime(DOB)].ToString();
                  dateTimePickerJoinDate.Value = dt.Rows[0][Convert.ToDateTime(JoinDate)].ToString();
  
                  //string Gender = null;
                  //if (radioButtonMale.Checked)
                  //{
                    //  Gender = "Male";
                  //}
                  //else
                  //{
                  //    Gender = "Female";
                  //}
                  //radioButtonMale.Checked = dt.Rows[0]["Gender"].ToString();
  
              }
  
              else
              {
                  MessageBox.Show("No Data in dt");
              }
  
          }
  </code></pre>
  
  <p>Please tell me how can i get the values of date in the datetimepicker control.
  I am working on windows application.
  Thanks in advance </p>