Reylin Mathew

Reylin Mathew

  • NA
  • 347
  • 75.6k

Conversion failed when converting time from charcter

Feb 6 2019 5:01 AM
Conversion failed when converting  time from character string
 
this is my code
 
 TextBox txtstaff_time = gvCalender.Rows[row.RowIndex].FindControl("txtstaff_time") as TextBox;
                    TimeSpan timeSpan = TimeSpan.Parse(txtstaff_time.Text);
 mg.ChangeCalender( txtstaff_time.Text);
 
public void ChangeCalender(string staffid, DateTime cal_date, string cal_day, string studoff, string stud_des, string staff_off, string staff_des,string stafftime, string nonstaff_off, string nonstaff_descr, string cal_year, string cal_month)
    {
        try
        {
            GetConnect();
            SqlCommand cmd = new SqlCommand("CAL_TEACHING_EXIT_TIME=@stafftime where CAL_DATE=@cal_date and CAL_DAY=@cal_day", SqlCon);
            cmd.Parameters.AddWithValue("@stafftime", stafftime);
            cmd.ExecuteNonQuery();
            SqlCon.Close();
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
 CAL_TEACHING_EXIT_TIME the filed datatype is time(7);
but this error is show.. how to solve?
plz help me..
 

Answers (2)