public static string ExecuteQueryToDisplayString(
            string query,
            string connectionString,
            Func <DbCommand> commandCreator)
        {
            if (string.IsNullOrEmpty(query))
            {
                return(string.Empty);
            }

            try
            {
                string[] dataset = null;
                var      headers = new StringBuilder();
                if (connectionString != null)
                {
                    dataset = DatabaseUtils.Query(query, connectionString, r => ConvertRowToString(r, headers)).ToArray();
                }
                else if (commandCreator != null)
                {
                    dataset = DatabaseUtils.Query(query, commandCreator, r => ConvertRowToString(r, headers)).ToArray();
                }

                return(headers + "\n" + string.Join("\n", dataset.OrEmpty().ToArray()));
            }
            catch (Exception ex)
            {
                return(ExceptionUtilities.FormatException(ex));
            }
        }