title: How can I query a DataGridView using SQL?
body: <p>I need to query a <code>DataGridView</code> using SQL but don't show to <code>DataGridView</code>.</p>
  
  <pre><code>public chkTime()
  {
      InitializeComponent();
  }
  
  HRTaffDataContext db = new HRTaffDataContext();
  SqlConnection Conn;
  SqlCommand cmd = new SqlCommand();
  SqlDataAdapter da;
  DataTable dt = new DataTable();
  DataSet ds = new DataSet();
  StringBuilder sb = new StringBuilder();
  string appConn = ConfigurationManager.ConnectionStrings["connDB"].ConnectionString;
  string strDate;
  
  private void chkTime_Load(object sender, EventArgs e)
  {
      connStr();
      return;
  }
  
  public void connStr()
  {
      Conn = new SqlConnection();
      if (Conn.State == ConnectionState.Open)
      {
          Conn.Close();
      }
      Conn.ConnectionString = appConn;
      Conn.Open();
  }
  
  private void button2_Click(object sender, EventArgs e)
  {
      SqlConnection conn = new SqlConnection(appConn);
  
      string sql = "SELECT [filesTA].EmpNo,[Employee].[First Name],[filesTA].ChkDate,[filesTA].ChkIn,[filesTA].ChkOut,[CompanyData].ShortName"
      + " From [WebSP].[dbo].[filesTA] inner join [WebSP].[dbo].[Employee] on [Employee].EmployeeNo=[filesTA].EmpNo INNER JOIN [WebSP].[dbo].[CompanyData] On [CompanyData].Company = [Employee].Company"
      + " WHERE [filesTA].ErrorCode = 0"; // It's work
      + " WHERE [filesTA].ErrorCode = 0 and [filesTA].ChkDate ='" + dateTimePicker.Text.ToString() + "'";
  
      da = new SqlDataAdapter(sql, Conn);
      DataSet ds = new DataSet();
      da.Fill(ds);
      Conn.Close();
  
      dgvShow.DataSource = ds.Tables[0];
  }
  </code></pre>
  
  <ul>
  <li><p><code>"WHERE [filesTA].ErrorCode = 0"</code> works fine. </p></li>
  <li><p><code>"WHERE [filesTA].ErrorCode = 0 and [filesTA].ChkDate ='" + dateTimePicker.Text.ToString() + "'"</code> does not work. </p></li>
  </ul>
  
  <p>I need to set where <code>DateTime</code>.</p>