Pavithra L

Pavithra L

  • NA
  • 336
  • 63.5k

Based on the date want to filter data's from datatable

Sep 2 2015 5:49 AM
In my project I am using report form. here I want to filter data based on from date to Todate.
Am I using two datetimepicker one for fromdate and one for Todate. 
Here is my code. This cannot filter the correct date values it can filter whole data's of that table.Kindly give me any suggestion to overcome this problem .
 
else if (comboBox1.Text == "Date Range")
{
SqlDataAdapter da = new SqlDataAdapter("select V_No,Date1,Employee,Reference,Purpose,S_No,Machine,Job_No,Item,Qty,UOM,T1,Prepared_By,Remarks from In_House_Issues where Date1 between '" + dateTimePicker1.Text + "' AND '" + dateTimePicker2.Text + "' ", con);
DataTable dt = new DataTable();
da.Fill(dt);
dataGridView1.DataSource = dt;
if (centeredContentOnpageToolStripMenuItem.Checked == true)
{
dataGridView1.Columns[12].Visible = false;
dataGridView1.Columns[13].Visible = false;
dataGridView1.Columns[14].Visible = false;
}
else
{
dataGridView1.Columns[12].Visible = true;
dataGridView1.Columns[13].Visible = true;
dataGridView1.Columns[14].Visible = true;
}
}
 

Answers (9)