public override DbDataAdapter GetAdapter(string selectCommand, DbConnection connection,
                                                 CommandParameterCollection parameters)
        {
            OracleDataAdapter adapter = new OracleDataAdapter(selectCommand, connection as OracleConnection);

            foreach (CommandParameter p in parameters)
            {
                OracleParameter parameter = adapter.SelectCommand.Parameters.Add(p.Name, (OracleDbType)p.DataType, p.Size);
                parameter.Value = p.Value;
            }
            return(adapter);
        }
        public override DbDataAdapter GetAdapter(string selectCommand, DbConnection connection,
                                                 CommandParameterCollection parameters)
        {
            VistaDBDataAdapter adapter = new VistaDBDataAdapter(selectCommand, connection as VistaDBConnection);

            foreach (CommandParameter p in parameters)
            {
                VistaDBParameter parameter = adapter.SelectCommand.Parameters.Add(p.Name, (VistaDBType)p.DataType, p.Size);
                object           value     = p.Value;
                parameter.Value = value is Variant ? ((Variant)value).Value : value;
            }
            return(adapter);
        }
Example #3
0
        public override void FillTableSchema(DataTable table, string selectCommand, CommandParameterCollection parameters)
        {
            CassandraConnectionStringBuilder builder = new CassandraConnectionStringBuilder(ConnectionString);

            using (DbConnection connection = GetConnection())
            {
                OpenConnection(connection);
                selectCommand = $"select * from {builder.DefaultKeyspace}.{table.TableName}";

                using (DbDataAdapter adapter = GetAdapter(selectCommand, connection, parameters))
                {
                    adapter.SelectCommand.CommandTimeout = CommandTimeout;
                    adapter.Fill(table);
                }
            }
        }
Example #4
0
        /// <inheritdoc/>
        public override DbDataAdapter GetAdapter(string selectCommand, DbConnection connection,
                                                 CommandParameterCollection parameters)
        {
            SqlDataAdapter adapter = new SqlDataAdapter(selectCommand, connection as SqlConnection);

            foreach (CommandParameter p in parameters)
            {
                SqlParameter parameter = adapter.SelectCommand.Parameters.Add(p.Name, (SqlDbType)p.DataType, p.Size);
                object       value     = p.Value;
                if ((SqlDbType)p.DataType == SqlDbType.UniqueIdentifier && (value is Variant || value is String))
                {
                    value = new Guid(value.ToString());
                }
                parameter.Value = value;
            }
            return(adapter);
        }
Example #5
0
        /// <summary>
        /// Fills the table schema.
        /// </summary>
        /// <param name="table">DataTable to fill.</param>
        /// <param name="selectCommand">The SQL select command.</param>
        /// <param name="parameters">SQL parameters.</param>
        /// <remarks>
        /// Usually you don't need to use this method. Internally it uses the <see cref="GetConnection"/> and
        /// <see cref="GetAdapter"/> methods to fill the table schema. If you create own connection component
        /// that does not use nor connection or adapter, then you need to override this method.
        /// </remarks>
        public virtual void FillTableSchema(DataTable table, string selectCommand,
                                            CommandParameterCollection parameters)
        {
            using (DbConnection conn = GetConnection())
            {
                OpenConnection(conn);

                // prepare select command
                selectCommand = PrepareSelectCommand(selectCommand, table.TableName, conn);

                // read the table schema
                using (DbDataAdapter adapter = GetAdapter(selectCommand, conn, parameters))
                {
                    adapter.SelectCommand.CommandTimeout = CommandTimeout;
                    adapter.FillSchema(table, SchemaType.Source);
                }
            }
        }
Example #6
0
 /// <inheritdoc/>
 public override void FillTableData(DataTable table, string selectCommand, CommandParameterCollection parameters)
 {
     // do nothing
 }
 /// <summary>
 /// Returns a <see cref="DbDataAdapter"/> object that is specific to this connection.
 /// </summary>
 /// <param name="selectCommand">The SQL command used to fetch a table data rows.</param>
 /// <param name="connection">The connection object.</param>
 /// <param name="parameters">The select command parameters.</param>
 /// <returns>The <b>DbDataAdapter</b> object.</returns>
 /// <remarks>
 /// You should override this method if you are developing a new connection component. In this method,
 /// you need to create the adapter and set its <b>SelectCommand</b>'s parameters.
 /// <para/>If your connection does not use data adapter, you need to override
 /// the <see cref="FillTableSchema"/> and <see cref="FillTableData"/> methods instead.
 /// </remarks>
 /// <example>Here is the example of this method implementation:
 /// <code>
 /// public override DbDataAdapter GetAdapter(string selectCommand, DbConnection connection,
 ///   CommandParameterCollection parameters)
 /// {
 ///   OleDbDataAdapter adapter = new OleDbDataAdapter(selectCommand, connection as OleDbConnection);
 ///   foreach (CommandParameter p in parameters)
 ///   {
 ///     OleDbParameter parameter = adapter.SelectCommand.Parameters.Add(p.Name, (OleDbType)p.DataType, p.Size);
 ///     parameter.Value = p.Value;
 ///   }
 ///   return adapter;
 /// }
 /// </code>
 /// </example>
 public virtual DbDataAdapter GetAdapter(string selectCommand, DbConnection connection,
                                         CommandParameterCollection parameters)
 {
     return(null);
 }
 /// <inheritdoc/>
 public override void FillTableData(DataTable table, string selectCommand,
                                    CommandParameterCollection parameters)
 {
     CreateDataTable(table, true);
 }
Example #9
0
        public override DbDataAdapter GetAdapter(string selectCommand, DbConnection connection, CommandParameterCollection parameters)
        {
            CqlDataAdapter adapter = new CqlDataAdapter();

            adapter.SelectCommand             = new CqlCommand();
            adapter.SelectCommand.Connection  = connection;
            adapter.SelectCommand.CommandText = selectCommand;
            foreach (DbParameter p in parameters)
            {
                CqlParameter parameter = new CqlParameter(p.ParameterName, p.Value);
                adapter.SelectCommand.Parameters.Add(parameter);
            }
            return(adapter);
        }
Example #10
0
        /// <inheritdoc/>
        public override DbDataAdapter GetAdapter(string selectCommand, DbConnection connection, FastReport.Data.CommandParameterCollection parameters)
        {
            SqlCeDataAdapter adapter = new SqlCeDataAdapter(selectCommand, connection as SqlCeConnection);

            foreach (CommandParameter p in parameters)
            {
                SqlCeParameter parameter = adapter.SelectCommand.Parameters.Add(p.Name, (SqlDbType)p.DataType, p.Size);
                parameter.Value = p.Value;
            }
            return(adapter);
        }
        public override DbDataAdapter GetAdapter(string selectCommand, DbConnection connection, CommandParameterCollection parameters)
        {
            ClickHouseDataAdapter adapter = new ClickHouseDataAdapter();

            adapter.SelectCommand             = new ClickHouseCommand(connection as ClickHouseConnection);
            adapter.SelectCommand.CommandText = selectCommand;

            foreach (CommandParameter p in parameters)
            {
                ClickHouseDbParameter parameter = new ClickHouseDbParameter();
                adapter.SelectCommand.Parameters.Add(p.Name);
                parameter.Value = p.Value;
            }
            return(adapter);
        }