Sazzadur

Sazzadur

  • NA
  • 19
  • 2.2k

How to Search date by two DateTimePickers

Mar 17 2018 2:35 PM
When I select date 3-5-18 to 3-17-18. The result is show only 3-5-18 to 3-16-18. And when I select 3-5-18 to 3-5-18 the result shows nothing on the Gridview.
 
My Coding
 
System.Data.SqlClient.SqlConnection cn= new System.Data.SqlClient.SqlConnection();
cnConnectionString=HR_And_Payroll.Propertys.Settings.Default. MyCon;
cn.Open();
SqlCommand cmd = new SqlCommand();
cmd.CommandType=CommandType.Text;
cmd.CommandText=" Select * Where Date >=@Date1 And Date<=@Date2"; cmd.Parameters. AddWithValue("@Date1", dateTimePicker1.Value);
cmd.Parameters. AddWithValue("@Date2", dateTimePicker2.Value);
 
Please anyone help me

Answers (1)