Posted on: 5/14/2014 5:39:36 PM | Views : 206


In my application  two customcalendar controls,  one searchbutton and GridView.If user enter dates in both textboxes  and click on search button  it display data in gridview .If user without entering dates in both textboxes   clicks on serach button  it shows  below error
The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value. private void SearchByDates() { string Connection = System.Configuration.ConfigurationManager.ConnectionStrings["Portal"].ConnectionString; SqlConnection cn = new SqlConnection(Connection); cn.Open(); SqlCommand cmd = new SqlCommand("select distinct EmpID,EmpName,StartDate,EndDate from Employee where StartDate="+ "'" + txt_StartDate.SelectedDate + "'" +"and"+" EndDate="  ...

Go to the complete details ...