I have the follwing problem in my ASP project :
i use LinQ to Retrive data including date however it throw an exception
the Code:
DateTime? castvar = DateTime.Parse(TextBox1.Text);
DateTime neededDay;
if (castvar != null)
{
neededDay = castvar.Value;
}
else
{
neededDay = DateTime.Now;
}
var DayReservations = (from r in db.reservations
join p in db.Clints on r.clintId equals p.ClintID
join d in db.Emplyees on r.doctorID equals d.EmpID
where r.apointDateStart.Date == neededDay.Date
&& r.apointDateStart.Month == neededDay.Month
&& r.apointDateStart.Day == neededDay.Day
&& r.doctorID == Convert.ToInt32(DoctorList.SelectedValue)
select new { p.Name, d.EmpName, r.apointDateStart, r.apointEndTime, r.suggestedProcedure, r.comment }).ToList();
the Exception :
Input string was not in a correct format.When converting a string to DateTime ,parse the string to take the date before putting each variable into the DateTime object.Make sure your method arguments are in right format.
this exception was thrown in the LinQ query
In the SQL the Reservation table is:
[clintId] = <clintId, int,>
,[doctorID] = <doctorID, int,>
,[apointDateStart] = <apointDateStart, datetime,>
,[apointDateEnd] = <apointDateEnd, datetime,>
,[comment] = <comment, nvarchar(max),>
,[suggestedProcedure] = <suggestedProcedure, nvarchar(max),>
where is the problem?????!!!!