Example #1
0
        internal static bool TableExists(MySqlConnection ExistingConnection, string TableName, MySqlTransaction SqlTransaction = null)
        {
            // pull the table details from the database
            var existsQuery = @"SELECT TABLE_NAME
                FROM information_schema.tables
                WHERE table_schema = @table_schema
                    AND table_name = @table_name
                LIMIT 1;";

            var tableName = RefinedResultsHelper.GetScalar <string>(ExistingConnection, existsQuery, new Dictionary <string, object>
            {
                ["@table_schema"] = ExistingConnection.Database,
                ["@table_name"]   = TableName
            }, SqlTransaction: SqlTransaction);

            return(!string.IsNullOrWhiteSpace(tableName));
        }
Example #2
0
 /// <summary>
 /// Query the database for a full table.
 /// </summary>
 /// <param name="EstablishedConnection">An open and established connection to a MySQL database.</param>
 /// <param name="QueryString">The full SQL query string to be used to retrieve the value requested.</param>
 /// <param name="Parameters">Named parameters for the query.</param>
 /// <param name="ThrowException">Throw exception or cache in LastExecutionException and continue.</param>
 /// <param name="SqlTransaction">Supply an existing transaction for use in this operation.</param>
 /// <returns>A full DataTable with requested data.</returns>
 public static DataTable GetDataTable(MySqlConnection EstablishedConnection, string QueryString, Dictionary <string, object> Parameters = null, bool ThrowException = true, MySqlTransaction SqlTransaction = null)
 => RefinedResultsHelper.GetDataTable(EstablishedConnection, QueryString, Parameters: Parameters, ThrowException: ThrowException, SqlTransaction: SqlTransaction);
Example #3
0
 /// <summary>
 /// Query the database for a full table.
 /// </summary>
 /// <param name="ConfigConnectionString">An enum type to reference a connection string defined in web.config.</param>
 /// <param name="QueryString">The full SQL query string to be used to retrieve the value requested.</param>
 /// <param name="Parameters">Named parameters for the query.</param>
 /// <param name="ThrowException">Throw exception or cache in LastExecutionException and continue.</param>
 /// <param name="AllowUserVariables">Will allow special user variables (variables start with "@") to be defined in the query that will be eventually executed.</param>
 /// <returns>A full DataTable with requested data.</returns>
 public static DataTable GetDataTable(Enum ConfigConnectionString, string QueryString, Dictionary <string, object> Parameters = null, bool ThrowException = true, bool AllowUserVariables = false)
 => RefinedResultsHelper.GetDataTable(ConfigConnectionString, QueryString, Parameters: Parameters, ThrowException: ThrowException, AllowUserVariables: AllowUserVariables);