ActivEarth.DAO.UserDAO.UpdatePassword C# (CSharp) Method

UpdatePassword() public static method

public static UpdatePassword ( string password, int userId, string &errorMessage ) : bool
password string
userId int
errorMessage string
return bool
        public static bool UpdatePassword(string password, int userId, out string errorMessage)
        {
            errorMessage = null;
            try
            {
                using (SqlConnection connection = ConnectionManager.GetConnection())
                {
                    var data = new ActivEarthDataProvidersDataContext(connection);
                    var user = (from u in data.UserDataProviders
                                where u.id == userId
                                select u).FirstOrDefault();
                    if (user != null)
                    {
                        user.password = password;
                        data.SubmitChanges();
                        return true;
                    }
                    return false;
                }
            }
            catch (Exception e)
            {
                errorMessage = e.ToString();
                return false;
            }
        }