Example #1
0
        private void CloseReader()
        {
            if (this._reader == null)
            {
                return;
            }
            SharpHsqlReader reader = (SharpHsqlReader)this._reader.Target;

            if ((reader != null) && this._reader.IsAlive)
            {
                if (!reader.IsClosed)
                {
                    reader.Close();
                }
            }
            this._reader = null;
        }
Example #2
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);
            }
        }