BusinessLogic.SqlMembershipProvider.UnlockUser C# (CSharp) Method

UnlockUser() public method

public UnlockUser ( string username ) : bool
username string
return bool
        public override bool UnlockUser(string username)
        {
            SqlConnection conn = new SqlConnection(connectionString);
            SqlCommand cmd = new SqlCommand("UPDATE Users " +
                                              " SET IsLockedOut = False, LastLockedOutDate = @LastLockedOutDate " +
                                              " WHERE Username = @Username AND ApplicationName = @ApplicationName", conn);

            cmd.Parameters.AddWithValue("@LastLockedOutDate", DateTime.Now);
            cmd.Parameters.AddWithValue("@Username", username);
            cmd.Parameters.AddWithValue("@ApplicationName", pApplicationName);

            int rowsAffected = 0;

            try
            {
                conn.Open();

                rowsAffected = cmd.ExecuteNonQuery();
            }
            catch (SqlException e)
            {
                if (WriteExceptionsToEventLog)
                {
                    WriteToEventLog(e, "UnlockUser");

                    throw new ProviderException(exceptionMessage);
                }
                else
                {
                    throw e;
                }
            }
            finally
            {
                conn.Close();
            }

            if (rowsAffected > 0)
                return true;

            return false;
        }