/// <summary> /// Returns a new cloned instance of the current parameter. /// </summary> /// <returns>The cloned <see cref="SharpHsqlParameter"/> instance.</returns> public SharpHsqlParameter Clone() { SharpHsqlParameter p = new SharpHsqlParameter(); p.SetProperties(this._name, this._sourceColumn, this._version, this._precision, this._scale, this._size, this._forceSize, this._offset, this._direction, this._value, this.DbType, this._suppress, this._inferType); return(p); }
private void RetrieveOutputParameters(Result result) { if (CommandText != null && CommandText != string.Empty && GetParameterCount() > 0) { int index = 0; for (int i = 0; i < Parameters.Count; i++) { SharpHsqlParameter p = Parameters[i]; string name = p.ParameterName.ToUpper(); if (name.IndexOf("@") > 0) { name = name.Substring(1, name.Length - 1); } if (ShouldSendParameter(p)) { p.Value = result.Root.Data[index]; index++; } } } }
private void ApplyParameterInfo(SharpHsqlParameter parameter, int pcount, DataRow row) { parameter.DbType = (DbType)Enum.Parse(typeof(DbType), row["ProviderType"].ToString()); parameter.IsNullable = (bool)row["AllowDBNull"]; if ((byte)row["Precision"] != byte.MaxValue) { parameter.Precision = (byte)row["Precision"]; } if ((byte)row["Scale"] != byte.MaxValue) { parameter.Scale = (byte)row["Scale"]; } parameter.Size = 0; }
private void RebuildNames() { lock (this) { _names.Clear(); for (int i = 0; i < base.InnerList.Count; i++) { SharpHsqlParameter p = base.InnerList[i] as SharpHsqlParameter; if (p != null) { _names[p.ParameterName] = i; } } } }
private bool ShouldSendParameter(SharpHsqlParameter p) { switch (p.Direction) { case ParameterDirection.Input: { return(false); } case ParameterDirection.Output: case ParameterDirection.InputOutput: { return(true); } case ParameterDirection.ReturnValue: { return(false); } } return(false); }
/// <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); } }