BusinessLogic.SqlMembershipProvider.GetUserNameByEmail C# (CSharp) Method

GetUserNameByEmail() public method

public GetUserNameByEmail ( string email ) : string
email string
return string
        public override string GetUserNameByEmail(string email)
        {
            SqlConnection conn = new SqlConnection(connectionString);
            SqlCommand cmd = new SqlCommand("SELECT Username" +
                  " FROM Users WHERE Email = @Email AND ApplicationName = @ApplicationName", conn);

            cmd.Parameters.AddWithValue("@Email", email);
            cmd.Parameters.AddWithValue("@ApplicationName", pApplicationName);

            string username = "";

            try
            {
                conn.Open();

                username = (string)cmd.ExecuteScalar();
            }
            catch (SqlException e)
            {
                if (WriteExceptionsToEventLog)
                {
                    WriteToEventLog(e, "GetUserNameByEmail");

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

            if (username == null)
                username = "";

            return username;
        }