Select * from participant_details where Datefrm>='" + Datefrm1 + "' and DateTo<='" + DateTo1 + "' ", vCon);
da.Fill(dt);
here Datefrm1 and DateTo1 are Datetimepickers values
i didn't get correct result when I use the above code
please solve my problem
Reagards
NagaRaju


Iftikar HussainRank #423 · 5.9K reputationPosted Jul 26, 2013, 4:27 AM EDT
Try like this
Regards,
Iftikar
Sanjeeb LenkaRank #301 · 8.3K reputationPosted Jul 26, 2013, 4:33 AM EDT
string Sql = "Select * from participant_details where Datefrm>=@Datefrm and DateTo<=@DateTo";
SqlCommand cmd = new SqlCommand(sql, conn);
cmd.Parameters.AddWithValue("@Datefrm",SqlDbType.DateTime).Value= Datefrm1;
cmd.Parameters.AddWithValue("@DateTo",SqlDbType.DateTime).Value= DateTo1;
DataTable dt = new DataTable();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dt);