shah Momin

shah Momin

  • NA
  • 176
  • 22.2k

String was not recognized as a valid DateTime

Jun 20 2022 6:53 AM

private void BtnTimteIn_Click(object sender, EventArgs e)
{
    try
    {

        SqlConnection connection = new SqlConnection(myconn);
        connection.Open();
        SqlCommand cmd = new SqlCommand("spCheckIn", connection);
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.AddWithValue("@ActionType", "SaveData");
        cmd.Parameters.AddWithValue("@CheckIn", (DateTime.Parse(dtpTimeIn.Text)));

        int NumRes = cmd.ExecuteNonQuery();
        if (NumRes > 0)
        {
            MessageBox.Show("Record Saved Successfully !!!", "Register", MessageBoxButtons.OK, MessageBoxIcon.Information);
            ClearAllData();
        }
        else
        {
            MessageBox.Show("Please Try Again !!!");
        }
        connection.Close();
    }
    catch (Exception ex)
    {
        MessageBox.Show("Error:- " + ex.Message);
    }

}

 


Answers (6)