title: Read data from sql database using datetime picker
body: <p>How to read data from database using datetimepicker value. I have a datetimepicker and a datagridview in my form. I want to get data from Sql databse table with the selected datetimepicker value. I try with this code</p>
  
  <pre><code>Private Sub BTNFIND_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNFIND.Click
      getConnect()
      Dim editdate As String
      DTPEDITAT.Value= Format(DTPEDITAT.Value, "dd/MM/yyyy")
      editdate = DTPEDITAT.Value
      MessageBox.Show(editdate)
      Try
          Conn.Open()
          Dim strSQL As String = "SELECT EMP_ID,EMP_NAME,AT_STATUS,AT_REMARK FROM ATTENDANCE WHERE AT_DATE = '" &amp; editdate &amp; "' ORDER BY EMP_NAME ASC"
          Dim da As SqlDataAdapter = New SqlDataAdapter(strSQL, Conn)
          Dim ds As DataSet = New DataSet
          da.Fill(ds, "ATTENDANCE")
          Dim dt As DataTable = ds.Tables("ATTENDANCE")
          Dim row As DataRow
          Dim atstat As String
          For Each row In dt.Rows
              If row("AT_STATUS") = 1 Then
                  atstat = "Present"
              ElseIf row("AT_STATUS") = 0 Then
                  atstat = "Absent"
              ElseIf row("AT_STATUS") = 0.5 Then
                  atstat = "Halfday"
              Else
                  atstat = "Error"
              End If
              For x As Integer = 0 To ATCEDITGRID.Rows.Count - 1
                  ATCEDITGRID.Rows(x).Cells(2).Value = row("EMP_ID")
                  ATCEDITGRID.Rows(x).Cells(3).Value = row("EMP_NAME")
                  ATCEDITGRID.Rows(x).Cells(0).Value = atstat
                  ATCEDITGRID.Rows(x).Cells(1).Value = row("AT_REMARK")
              Next x
          Next row
      Catch ex As SqlException
          MsgBox(ex.Message, MsgBoxStyle.Critical, "SQL Error")
      Catch ex As Exception
          MsgBox(ex.Message, MsgBoxStyle.Critical, "General Error")
      End Try
  End Sub
  </code></pre>
  
  <p>Datagridview not display anything and there is no error...</p>