I have a winform application which contains a datetimepicker. When I select a date it gives that date sale details. I have added the code to form load event also, but I get a SqlDateTime overflow error. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.
my code is
DateTime fromDate, toDate;
DateTime.TryParse(dateTimePicker_FromByDateSaleReport.Text, out fromDate);
DateTime.TryParse(dateTimePicker_ToByDateSaleReport.Text, out toDate);
SqlDataAdapter da3 = new SqlDataAdapter("SELECT Bill_Date,Name,Item,Item_Code,MRP, Quantity,Amount as Total, Amount_After_Discount as Grand_Total From POS LEFT JOIN Customers ON POS.Customer=Customers.Customer_Id WHERE Bill_Date Between @From AND @To", con);
da3.SelectCommand.Parameters.AddWithValue("@From", SqlDbType.DateTime).Value = fromDate;
da3.SelectCommand.Parameters.AddWithValue("@To", SqlDbType.DateTime).Value = toDate;
DataTable dt3 = new DataTable();
da3.Fill(dt);
dgv_ByDateSaleReport.DataSource = dt3;
}
.