How to Solve it?
Error is :-
Conversion failed when converting date and/or time from character string.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: Conversion failed when converting date and/or time from character string.
Source Error:
Line 75: da.SelectCommand.Parameters.AddWithValue("start", start);
Line 76: da.SelectCommand.Parameters.AddWithValue("end",end);
Line 77: DataTable dt = new DataTable();
Line 78: da.Fill(dt);
Line 79:
Source File: d:\Maik enviro\erp\DAL\Db.cs Line: 77
Code:-
private void LoadAppointments()
{
DataTable table = DAL.Db.LoadAppointments(DayPilotScheduler1.VisibleStart, DayPilotScheduler1.VisibleEnd);
DayPilotScheduler1.DataSource = table;
DayPilotScheduler1.DataIdField = "ID";
DayPilotScheduler1.DataTextField = "Name";
DayPilotScheduler1.DataStartField = "App_Date";
DayPilotScheduler1.DataEndField = "AppointmentEnd";
DayPilotScheduler1.DataTagFields = "AppointmentStatus";
DayPilotScheduler1.DataResourceField = "Team_id";
DayPilotScheduler1.DataBind();
DayPilotScheduler1.Update();
}
DAL.Db.LoadAppointments Is:-
public static DataTable LoadAppointments(DateTime start, DateTime end)
{
SqlDataAdapter da = new SqlDataAdapter("SELECT ( Client_Master.First_Name + Client_Master.Last_Name) AS Name, Client_Master.Company_Name, Appointments.Team_id,Appointments.ID, Appointments.App_Date, Appointments.AppointmentEnd, Appointments.AppointmentStatus, Appointments.Remark FROM Appointments INNER JOIN Client_Master ON Appointments.Client_id = Client_Master.Client_id WHERE NOT (([AppointmentEnd] <= '" + start + "') OR ([App_Date] >= '" + end + "'))", "Data Source=118.67.248.175;Initial Catalog=NaikEnviro;Persist Security Info=True;User ID=''''''''''''''''';Password=............;Connect Timeout=720000;");
da.SelectCommand.Parameters.AddWithValue("start", start);
da.SelectCommand.Parameters.AddWithValue("end",end);
DataTable dt = new DataTable();
da.Fill(dt);
return dt;
}