コード例 #1
0
 /// <summary>
 /// Derive command parameters.
 /// </summary>
 /// <param name="command"></param>
 public static void DeriveParameters(SharpHsqlCommand command)
 {
     if (command == null)
     {
         throw new ArgumentNullException("command");
     }
     command.DeriveParameters();
 }
コード例 #2
0
        /// <summary>
        /// Internal constructor
        /// </summary>
        /// <param name="command"></param>
        internal SharpHsqlReader(SharpHsqlCommand command)
        {
            _first    = true;
            _command  = command;
            _behavior = CommandBehavior.Default;
            _rs       = command.Result;
            _columns  = new Hashtable();
            int count = _rs.ColumnCount;

            for (int i = 0; i < count; i++)
            {
                _columns.Add(_rs.Label [i], i);
            }
        }
コード例 #3
0
        /// <summary>
        /// Makes a clone of the current object.
        /// </summary>
        /// <returns></returns>
        public object Clone()
        {
            SharpHsqlCommand cmd = new SharpHsqlCommand();

            cmd.CommandText      = this.CommandText;
            cmd.CommandType      = this.CommandType;
            cmd.UpdatedRowSource = this.UpdatedRowSource;
            IDataParameterCollection parameters = cmd.Parameters;

            foreach (ICloneable parameter in this.Parameters)
            {
                parameters.Add(parameter.Clone());
            }
            cmd.Connection     = this.Connection;
            cmd.Transaction    = this.Transaction;
            cmd.CommandTimeout = this.CommandTimeout;
            return(cmd);
        }
コード例 #4
0
 /// <summary>
 /// Constructor using a command text string.
 /// </summary>
 /// <param name="selectCommandText"></param>
 public SharpHsqlDataAdapter(string selectCommandText) : this()
 {
     _selectCommand = new SharpHsqlCommand(selectCommandText, new SharpHsqlConnection());
 }
コード例 #5
0
 /// <summary>
 /// Constructor using a <see cref="SharpHsqlCommand"/> object.
 /// </summary>
 /// <param name="selectCommand"></param>
 public SharpHsqlDataAdapter(SharpHsqlCommand selectCommand) : this()
 {
     _selectCommand = selectCommand;
 }
コード例 #6
0
 /// <summary>
 /// Constructor using a command text string and a select connection string.
 /// </summary>
 /// <param name="selectCommandText"></param>
 /// <param name="selectConnectionString"></param>
 public SharpHsqlDataAdapter(string selectCommandText, string selectConnectionString)
 {
     _selectCommand = new SharpHsqlCommand(selectCommandText, new SharpHsqlConnection(selectConnectionString));
 }
コード例 #7
0
        /// <summary>
        /// Derive parameters from a stored procedure.
        /// </summary>
        internal void DeriveParameters()
        {
            CommandType type = this.CommandType;

            if (type == CommandType.Text)
            {
                throw new InvalidOperationException("Derive Parameters Not Supported");
            }
            if (type != CommandType.StoredProcedure)
            {
                if (type == CommandType.TableDirect)
                {
                    throw new InvalidOperationException("Derive Parameters Not Supported");
                }
                throw new InvalidOperationException("Invalid CommandType");
            }
            this.ValidateCommand("DeriveParameters", false);
            SharpHsqlCommand command = new SharpHsqlCommand("sp_procedure_params_rowset", this._connection);

            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add(new SharpHsqlParameter("@procedure_name", DbType.String, 0xff));
            command.Parameters[0].Value = this._commandText;
            ArrayList list = new ArrayList();

            try
            {
                try
                {
                    SharpHsqlReader reader = command.ExecuteReader();
                    try
                    {
                        SharpHsqlParameter parameter = null;
                        while (reader.Read())
                        {
                            parameter = new SharpHsqlParameter();
                            parameter.ParameterName = (string)reader["PARAMETER_NAME"];
                            //parameter1.DbType = MetaType.GetSqlDbTypeFromOleDbType((short) reader1["DATA_TYPE"], (string) reader1["TYPE_NAME"]);
                            object obj = reader["CHARACTER_MAXIMUM_LENGTH"];
                            if (obj is int)
                            {
                                parameter.Size = (int)obj;
                            }
                            //parameter1.Direction = this.ParameterDirectionFromOleDbDirection((short) reader1["PARAMETER_TYPE"]);
                            if (parameter.DbType == DbType.Decimal)
                            {
                                parameter.Scale     = (byte)(((short)reader["NUMERIC_SCALE"]) & 0xff);
                                parameter.Precision = (byte)(((short)reader["NUMERIC_PRECISION"]) & 0xff);
                            }
                            list.Add(parameter);
                        }
                    }
                    finally
                    {
                        if (reader != null)
                        {
                            ((IDisposable)reader).Dispose();
                        }
                    }
                }
                finally
                {
                    command.Connection = null;
                }
            }
            catch
            {
                throw;
            }
            if (list.Count == 0)
            {
                throw new InvalidOperationException("No Stored Procedure Exists with that name");
            }
            this.Parameters.Clear();
            foreach (object p in list)
            {
                this._parameters.Add(p);
            }
        }
コード例 #8
0
 /// <summary>
 /// Internal Constructor.
 /// </summary>
 /// <param name="command"></param>
 internal SharpHsqlParameterCollection(SharpHsqlCommand command) : base()
 {
     _command = command;
     _names   = new Hashtable();
 }
コード例 #9
0
 public SharpHsqlParameterCollection(SharpHsqlCommand cmd)
 {
     _cmd = cmd;
 }