how to convert datetime to time sapn

May 7 2019 9:18 AM
hi friends
 
protected void btn_valid_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection();
con.ConnectionString = ConfigurationManager.ConnectionStrings["Const"].ToString();
SqlCommand cmd = new SqlCommand("VALL", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@EMP_ID", SqlDbType.Int).Value = int.Parse (txt_emp_id.Text);
cmd.Parameters.Add("@IN_TIME", SqlDbType.Time).Value = Convert.ToDateTime (txt_present_In_time.Text);
cmd.Parameters.Add("@OUT_TIME", SqlDbType.Time).Value = Convert.ToDateTime (txt_present_out_time.Text);
cmd.Parameters.Add("@OUTPUT_PARA", SqlDbType.VarChar, 20);
cmd.Parameters["@OUTPUT_PARA"].Direction = ParameterDirection.Output;
con.Open();
cmd.ExecuteNonQuery();
con.Close();
lbl_rect_err_msg.Text = cmd.Parameters["@OUTPUT_PARA"].Value.ToString();
}
 
 
ERROR MESSAGE::
 
 Additional information: Failed to convert parameter value from a DateTime to a TimeSpan.
 
 HELP ME!!!!!!!!!!!
 

Answers (2)