private SqlParameter Add(SqlParameter SqlPar, System.Data.ParameterDirection direction, object value)
 {
     SqlCmd.CommandType = CommandType.StoredProcedure;
     SqlPar.Value       = value;
     SqlPar.Direction   = direction;
     return(SqlCmd.Parameters.Add(SqlPar));
 }
        private int SetParameter(ref SqlCommand cm, string ParameterName, Object Value
                                 , System.Data.SqlDbType ParameterType, int FieldSize = -1
                                 , System.Data.ParameterDirection Direction           = System.Data.ParameterDirection.Input
                                 , Byte Precision = 0, Byte Scale = 0)
        {
            try
            {
                cm.CommandType = System.Data.CommandType.StoredProcedure;
                if (FieldSize == -1)
                {
                    cm.Parameters.Add(ParameterName, ParameterType);
                }
                else
                {
                    cm.Parameters.Add(ParameterName, ParameterType, FieldSize);
                }

                if (Precision > 0)
                {
                    cm.Parameters[cm.Parameters.Count - 1].Precision = Precision;
                }
                if (Scale > 0)
                {
                    cm.Parameters[cm.Parameters.Count - 1].Scale = Scale;
                }

                cm.Parameters[cm.Parameters.Count - 1].Value     = Value;
                cm.Parameters[cm.Parameters.Count - 1].Direction = Direction;

                return(0);
            }
            catch (Exception ex) { throw new Exception(ex.Message); }
        }
 public ParameterWrapper(string name, SqlDbType type, object value, System.Data.ParameterDirection direction, string typename)
 {
     this._Type      = type;
     this._Name      = name;
     this._Value     = value;
     this._Direction = direction;
     this._TypeName  = typename;
 }
Exemple #4
0
 public DBParameter(string _ParameterName, System.Data.SqlDbType _DbType, int _Size, System.Data.ParameterDirection _ParameterDirection, object _ParamValue)
 {
     ParameterName      = _ParameterName;
     DbType             = _DbType;
     Size               = _Size;
     ParameterDirection = _ParameterDirection;
     ParamValue         = _ParamValue;
 }
 internal MySqlParameter(string name, MySqlDbType type, ParameterDirection dir, string col, DataRowVersion ver, object val)
   : this(name, type)
 {
   Direction = dir;
   SourceColumn = col;
   SourceVersion = ver;
   Value = val;
 }
Exemple #6
0
        /// <summary>
        /// Adiciona um parametro usado na stored procedure.
        /// </summary>
        /// <param name="name">Nome do parametro.</param>
        /// <param name="value">Valor do parametro.</param>
        /// <param name="direction">Direção do parametro.</param>
        /// <param name="dbType">Tipo do parametro.</param>
        /// <returns>Referência da atual stored procedure.</returns>
        public GDAStoredProcedure AddParameter(string name, object value, System.Data.ParameterDirection direction, System.Data.DbType dbType)
        {
            var p = new GDAParameter(name, value, direction);

            p.DbType = dbType;
            _parameters.Add(p);
            return(this);
        }
 internal MyCatParameter(string name, MyCatDbType type, ParameterDirection dir, string col, DataRowVersion ver, object val)
     : this(name, type)
 {
     Direction     = dir;
     SourceColumn  = col;
     SourceVersion = ver;
     Value         = val;
 }
Exemple #8
0
        public int AddParameter(string name, object value, System.Data.ParameterDirection parameterDirection)
        {
            DbParameter p = objFactory.CreateParameter();

            p.ParameterName = name;
            p.Value         = value;
            p.Direction     = parameterDirection;
            return(objCommand.Parameters.Add(p));
        }
Exemple #9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="name"></param>
        /// <param name="dbType"></param>
        /// <param name="direction"></param>
        /// <param name="size"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public override System.Data.IDbDataParameter CreateParameter(
            string name, int dbType, System.Data.ParameterDirection direction, int size, object value)
        {
            SqlParameter __parameter = new SqlParameter(name, (SqlDbType)dbType, size);

            __parameter.Direction = direction;
            __parameter.Value     = value;
            return(__parameter);
        }
        public int Add(string ParameterName, object Value, System.Data.ParameterDirection Direction, SqlDbType DbType)
        {
            SqlParameter oParameter = new SqlParameter();

            oParameter.ParameterName = ParameterName;
            oParameter.Value         = Value;
            oParameter.Direction     = Direction;
            oParameter.SqlDbType     = DbType;
            return(this.Add(oParameter));
        }
Exemple #11
0
        protected SqlParameter ObjSqlParameter(string pParameterName, object pValue, System.Data.ParameterDirection pDirection, DbType pDbType)
        {
            SqlParameter lSqlParameter = new SqlParameter();

            lSqlParameter.ParameterName = pParameterName;
            lSqlParameter.Value         = pValue;
            lSqlParameter.Direction     = pDirection;
            lSqlParameter.DbType        = pDbType;
            return(lSqlParameter);
        }
 void GetOracleDbDirection(_OracleDbDirection pOracleDbDirection, ref System.Data.ParameterDirection pDAOracleDbDirection)
 {
     if (pOracleDbDirection == _OracleDbDirection.OraInput)
     {
         pDAOracleDbDirection = ParameterDirection.Input;
     }
     else if (pOracleDbDirection == _OracleDbDirection.OraOutput)
     {
         pDAOracleDbDirection = ParameterDirection.Output;
     }
 }
Exemple #13
0
        public MySqlParameter ObjSqlParameter(string pParameterName, object pValue, System.Data.ParameterDirection pDirection, DbType pDbType, Int32 psize)
        {
            MySqlParameter lSqlParameter = new MySqlParameter();

            lSqlParameter.ParameterName = pParameterName;
            lSqlParameter.Value         = pValue;
            lSqlParameter.Direction     = pDirection;
            lSqlParameter.DbType        = pDbType;
            lSqlParameter.Size          = psize;
            return(lSqlParameter);
        }
        private MySQLParameter CreateParameter(string parameterName, System.Data.DbType dbType,
                                               int size, object val, System.Data.ParameterDirection parameterDirection)
        {
            MySQLParameter res = new MySQLParameter();

            res.ParameterName = parameterName;
            res.DbType        = dbType;
            res.Size          = size;
            res.Value         = val;
            res.Direction     = parameterDirection;
            return(res);
        }
 public void Add(string name, System.Data.SqlDbType type, object value, System.Data.ParameterDirection direction, string typename)
 {
     try
     {
         ParameterWrapper TmpItem = new ParameterWrapper(name, type, value, direction, typename);
         List.Add(TmpItem);
         TmpItem = null;
     } catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #16
0
        public void AddParameter(string name, object value, System.Data.ParameterDirection direction)
        {
            MySqlParameter parameterTmp = new MySqlParameter();

            parameterTmp.ParameterName = name;
            parameterTmp.Direction     = direction;
            if (parameterTmp.Direction == ParameterDirection.Input | parameterTmp.Direction == ParameterDirection.InputOutput)
            {
                parameterTmp.Value = value;
            }
            _parametersArray.Add(parameterTmp);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="MyCatParameter"/> class with the parameter name, the type of the parameter, the size of the parameter, a <see cref="ParameterDirection"/>, the precision of the parameter, the scale of the parameter, the source column, a <see cref="DataRowVersion"/> to use, and the value of the parameter.
 /// </summary>
 /// <param name="parameterName">The name of the parameter to map. </param>
 /// <param name="dbType">One of the <see cref="MyCatDbType"/> values. </param>
 /// <param name="size">The length of the parameter. </param>
 /// <param name="direction">One of the <see cref="ParameterDirection"/> values. </param>
 /// <param name="isNullable">true if the value of the field can be null, otherwise false. </param>
 /// <param name="precision">The total number of digits to the left and right of the decimal point to which <see cref="MyCatParameter.Value"/> is resolved.</param>
 /// <param name="scale">The total number of decimal places to which <see cref="MyCatParameter.Value"/> is resolved. </param>
 /// <param name="sourceColumn">The name of the source column. </param>
 /// <param name="sourceVersion">One of the <see cref="DataRowVersion"/> values. </param>
 /// <param name="value">An <see cref="Object"/> that is the value of the <see cref="MyCatParameter"/>. </param>
 /// <exception cref="ArgumentException"/>
 public MyCatParameter(string parameterName, MyCatDbType dbType, int size, ParameterDirection direction,
                       bool isNullable, byte precision, byte scale, string sourceColumn,
                       DataRowVersion sourceVersion,
                       object value)
     : this(parameterName, dbType, size, sourceColumn)
 {
     Direction     = direction;
     SourceVersion = sourceVersion;
     IsNullable    = isNullable;
     Precision     = precision;
     Scale         = scale;
     Value         = value;
 }
        public void AddParameter(string name, object value, System.Data.ParameterDirection direction, DbType DBFieldType)
        {
            SqlParameter parameterTmp = new SqlParameter();

            parameterTmp.ParameterName = name;
            parameterTmp.Direction     = direction;
            parameterTmp.DbType        = DBFieldType;
            if (parameterTmp.Direction == ParameterDirection.Input | parameterTmp.Direction == ParameterDirection.InputOutput)
            {
                parameterTmp.Value = value;
            }
            _parametersArray.Add(parameterTmp);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="MySqlParameter"/> class with the parameter name, the type of the parameter, the size of the parameter, a <see cref="ParameterDirection"/>, the precision of the parameter, the scale of the parameter, the source column, a <see cref="DataRowVersion"/> to use, and the value of the parameter.
 /// </summary>
 /// <param name="parameterName">The name of the parameter to map. </param>
 /// <param name="dbType">One of the <see cref="MySqlDbType"/> values. </param>
 /// <param name="size">The length of the parameter. </param>
 /// <param name="direction">One of the <see cref="ParameterDirection"/> values. </param>
 /// <param name="isNullable">true if the value of the field can be null, otherwise false. </param>
 /// <param name="precision">The total number of digits to the left and right of the decimal point to which <see cref="MySqlParameter.Value"/> is resolved.</param>
 /// <param name="scale">The total number of decimal places to which <see cref="MySqlParameter.Value"/> is resolved. </param>
 /// <param name="sourceColumn">The name of the source column. </param>
 /// <param name="sourceVersion">One of the <see cref="DataRowVersion"/> values. </param>
 /// <param name="value">An <see cref="Object"/> that is the value of the <see cref="MySqlParameter"/>. </param>
 /// <exception cref="ArgumentException"/>
 public MySqlParameter(string parameterName, MySqlDbType dbType, int size, ParameterDirection direction,
                       bool isNullable, byte precision, byte scale, string sourceColumn,
                       DataRowVersion sourceVersion,
                       object value)
   : this(parameterName, dbType, size, sourceColumn)
 {
   Direction = direction;
   SourceVersion = sourceVersion;
   IsNullable = isNullable;
   Precision = precision;
   Scale = scale;
   Value = value;
 }
Exemple #20
0
        public static System.Data.DataTable dtParams()
        {
            System.Data.DbType             tipo      = new System.Data.DbType();
            System.Data.ParameterDirection direccion = new System.Data.ParameterDirection();
            System.Data.DataTable          dt        = new System.Data.DataTable();
            dt.Columns.Add("Nombre", System.Type.GetType("System.String"));
            dt.Columns.Add("Tipo", tipo.GetType());
            dt.Columns.Add("Size", System.Type.GetType("System.Int32"));
            dt.Columns.Add("Direccion", direccion.GetType());
            dt.Columns.Add("Valor", System.Type.GetType("System.Object"));

            return(dt);
        }
        public override string GetCommand(Column column, string parameterName, System.Data.ParameterDirection parameterDirection, DataRowVersion dataRowVersion, bool isNullable)
        {
            SqlDbType sqlDbType = (SqlDbType)Enum.Parse(typeof(SqlDbType), column.OriginalSQLType);

            return(string.Format("System.Data.SqlClient.SqlParameter(\"{0}\", System.Data.SqlDbType.{1}, {2}, System.Data.ParameterDirection.{3}, {4}, (System.Byte)({5}), (System.Byte)({6}), \"{7}\", System.Data.DataRowVersion.{8}, null)",
                                 parameterName,                 /*The name of the parameter*/
                                 sqlDbType.ToString(),          /*One of the OleDbType values*/
                                 column.Length.ToString(),      /*The length of the parameter*/
                                 parameterDirection.ToString(), /*One of the ParameterDirection values*/
                                 isNullable.ToString(),
                                 column.Precision.ToString(),   /*The total number of digits to the left and right of the decimal point to which Value is resolved*/
                                 column.Scale.ToString(),       /*The total number of decimal places to which Value is resolved*/
                                 column.Name,                   /*The name of the source column*/
                                 dataRowVersion.ToString()
                                 ));
        }
Exemple #22
0
        internal static NpgsqlParameter GetEAParam(DateTime?expiresAt, System.Data.ParameterDirection direction)
        {
            NpgsqlParameter p = new NpgsqlParameter("ea", NpgsqlTypes.NpgsqlDbType.TimestampTZ);

            p.Direction  = direction;
            p.IsNullable = true;
            if (expiresAt.HasValue)
            {
                p.Value = expiresAt.Value;
            }
            else
            {
                p.Value = DBNull.Value;
            }
            return(p);
        }
Exemple #23
0
        private SqlParameter CreateSqlParameter(string parameterName,
                                                SqlDbType dataType, int size,
                                                string srcColumn, System.Data.ParameterDirection direction,
                                                System.Data.DataRowVersion srcVersion)
        {
            SqlParameter myParameter = new SqlParameter();

            myParameter.ParameterName = parameterName;
            myParameter.SqlDbType     = dataType;
            myParameter.Size          = size;
            myParameter.SourceColumn  = srcColumn;
            myParameter.Direction     = direction;
            myParameter.SourceVersion = srcVersion;

            return(myParameter);
        }
Exemple #24
0
        public Parameter(string nName, DbType nType, string nSpecificType, object nValue, bool nIsNullable, int nMaxLength, byte nPrecision, byte nScale, System.Data.ParameterDirection nDirection, FilterOption nFilterOption, int nFilterGroup)
        {
            Name         = nName;
            Type         = nType;
            Value        = nValue;
            IsNullable   = nIsNullable;
            MaxLength    = nMaxLength;
            Precision    = nPrecision;
            Scale        = nScale;
            Direction    = nDirection;
            SpecificType = nSpecificType;

            FilterOption = nFilterOption;
            FilterGroup  = nFilterGroup;

            //ComparitionType = ComparitionType.Equal;
        }
Exemple #25
0
        /// <summary>
        /// 参数定义
        /// </summary>
        /// <param name="name"></param>
        /// <param name="value"></param>
        /// <param name="parameterType"></param>
        /// <param name="direction"></param>
        /// <param name="size"></param>
        /// <returns></returns>
        public IDbCommand Parameter(string name
                                    , object value
                                    , System.Data.DbType parameterType         = System.Data.DbType.Object
                                    , System.Data.ParameterDirection direction = System.Data.ParameterDirection.Input
                                    , int size = 0)
        {
            if (value == null)
            {
                value = DBNull.Value;
            }

            if (value.GetType().IsEnum)
            {
                value = (int)value;
            }

            var dbParameter = Data.InnerCommand.CreateParameter();

            if (parameterType == System.Data.DbType.Object)
            {
                dbParameter.DbType = (System.Data.DbType)Data.Context.Data.Provider.GetDbTypeForClrType(value.GetType());
            }
            else
            {
                dbParameter.DbType = parameterType;
            }

            dbParameter.ParameterName = Data.Context.Data.Provider.GetParameterName(name);
            dbParameter.Direction     = direction;
            if (value == null)
            {
                dbParameter.Value = DBNull.Value;
            }
            else
            {
                dbParameter.Value = value;
            }
            if (size > 0)
            {
                dbParameter.Size = size;
            }

            Data.InnerCommand.Parameters.Add(dbParameter);

            return(this);
        }
Exemple #26
0
        private QueryParameterDirection GetParamDirection(SysParameterDirection direction)
        {
            if (direction == SysParameterDirection.Input)
            {
                return(QueryParameterDirection.In);
            }
            if (direction == SysParameterDirection.Output)
            {
                return(QueryParameterDirection.Out);
            }
            if (direction == SysParameterDirection.InputOutput)
            {
                return(QueryParameterDirection.InOut);
            }

            throw new NotSupportedException();
        }
        private QueryParameterDirection GetParamDirection(SysParameterDirection direction)
        {
            switch (direction)
            {
            case ParameterDirection.Input:
            default:
                return(QueryParameterDirection.In);

            case ParameterDirection.InputOutput:
                return(QueryParameterDirection.InOut);

            case ParameterDirection.Output:
                return(QueryParameterDirection.Out);

            case ParameterDirection.ReturnValue:
                throw new NotImplementedException();
            }
        }
        internal void AddParameter <T>(string chave, T valor, System.Data.ParameterDirection direcao = System.Data.ParameterDirection.Input)
        {
            if (this.Parametros == null)
            {
                this.Parametros = new Dictionary <string, Parametro>();
            }

            if (this.Parametros.ContainsKey(chave))
            {
                this.Parametros.Remove(chave);
            }

            if (!object.Equals(valor, default(T)))
            {
                this.Parametros.Add(chave, new Parametro {
                    Valor = valor, Direcao = direcao
                });
            }
        }
        protected override object GetParameter(string name, System.Data.ParameterDirection direction, int dbType, int size = 0, object value = null)
        {
            SqlParameter param = new SqlParameter();

            param.Direction = direction;
            param.SqlDbType = (System.Data.SqlDbType)dbType;

            if (size > 0)
            {
                param.Size = size;
            }

            if (value != null)
            {
                param.Value = value;
            }

            param.ParameterName = name;

            return(param);
        }
        /// <summary>
        /// 创建 SQL 命令参数。
        /// </summary>
        /// <param name="parameterName">参数名称。</param>
        /// <param name="value">参数的值。</param>
        /// <param name="direction">获取或设置一个值,该值指示参数是只可输入、只可输出、双向还是存储过程返回值参数。</param>
        /// <returns></returns>
        public override IDbDataParameter CreateParameter(string parameterName, object value, System.Data.ParameterDirection direction)
        {
            IDbDataParameter p = CreateParameter(parameterName, value);

            p.Direction = direction;
            return(p);
        }
Exemple #31
0
        /// <summary>
        /// Gets the list of sql parameters.
        /// </summary>
        /// <param name="functionParameters">The function parameters created.</param>
        /// <param name="functionValues">The function values created.</param>
        /// <param name="methodInfo">The current method information.</param>
        /// <param name="parameters">The parameter collection.</param>
        /// <returns>The list of parameters.</returns>
        public DbParameter[] GetParameters(ref string functionParameters, ref string functionValues,
                                           MethodInfo methodInfo, params Object[] parameters)
        {
            int    i             = -1;
            long   length        = -1;
            string dbType        = null;
            bool   isNullable    = true;
            string parameterName = null;

            System.Data.ParameterDirection parameterDirection = ParameterDirection.Input;

            // Create a new instance of the sql parameter collection.
            string functionParameterNames = string.Empty;
            string functionValueNames     = string.Empty;
            List <System.Data.SqlClient.SqlParameter> sqlParameters = new List <SqlParameter>();
            DataTypeConversion dataTypeConversion = new DataTypeConversion(ConnectionContext.ConnectionDataType.SqlDataType);

            // For each parameter within the method.
            foreach (ParameterInfo parameter in methodInfo.GetParameters())
            {
                // For each attribute for the parameter.
                foreach (object attribute in parameter.GetCustomAttributes(true))
                {
                    // If the attribute is the
                    // function parameter column attribute.
                    if (attribute is Nequeo.Data.Custom.FunctionParameterAttribute)
                    {
                        // Increment the parameter count.
                        i++;

                        // Cast the current attribute.
                        Nequeo.Data.Custom.FunctionParameterAttribute att =
                            (Nequeo.Data.Custom.FunctionParameterAttribute)attribute;

                        dbType             = att.DbType;
                        length             = att.Length;
                        parameterName      = att.Name;
                        isNullable         = att.IsNullable;
                        parameterDirection = att.ParameterDirection;

                        // Add each parameter to the collection.
                        sqlParameters.Add(new System.Data.SqlClient.SqlParameter(
                                              parameterName, Nequeo.Data.SqlServer.ClientDataType.GetSqlDbType(dbType), Convert.ToInt32(length),
                                              parameterDirection, isNullable, ((Byte)(0)), ((Byte)(0)), "", System.Data.DataRowVersion.Current, parameters[i]));

                        // If the parameter is an input type
                        // then add the parameter to the list.
                        if (parameterDirection == ParameterDirection.Input || parameterDirection == ParameterDirection.InputOutput)
                        {
                            functionParameterNames += parameterName + ", ";
                            functionValueNames     += dataTypeConversion.GetSqlStringValue(parameters[i].GetType(), parameters[i]) + ", ";
                        }
                    }
                }
            }


            // Get the parameters for the function and
            // add the last return value parameter.
            functionParameters = functionParameterNames.TrimEnd(' ', ',');
            functionValues     = functionValueNames.TrimEnd(' ', ',');
            sqlParameters.Add(new System.Data.SqlClient.SqlParameter("@RETURN_VALUE", SqlDbType.Int, 4,
                                                                     ParameterDirection.ReturnValue, false, ((Byte)(0)), ((Byte)(0)), "", DataRowVersion.Current, null));

            // Return the sql parameters.
            return(sqlParameters.ToArray());
        }
Exemple #32
0
        protected static XrDbParameter CreateParameter(string sParameterName, object oParameterValue, XDbType DbType, int iSize, System.Data.ParameterDirection direction)
        {
            XrDbParameter oParam;

            if (iSize != 0)
            {
                oParam = new XrDbParameter(sParameterName, (XrDbType)DbType, iSize);
            }
            else
            {
                oParam = new XrDbParameter(sParameterName, (XrDbType)DbType);
            }

            oParam.Direction = direction;
            oParam.Value     = oParameterValue;

            return(oParam);
        }
Exemple #33
0
 private QueryParameterDirection GetParamDirection(SysParameterDirection direction)
 {
     switch (direction) {
         case ParameterDirection.Input:
         default:
             return QueryParameterDirection.In;
         case ParameterDirection.InputOutput:
             return QueryParameterDirection.InOut;
         case ParameterDirection.Output:
             return QueryParameterDirection.Out;
         case ParameterDirection.ReturnValue:
             throw new NotImplementedException();
     }
 }
        private QueryParameterDirection GetParamDirection(SysParameterDirection direction)
        {
            if (direction == SysParameterDirection.Input)
                return QueryParameterDirection.In;
            if (direction == SysParameterDirection.Output)
                return QueryParameterDirection.Out;
            if (direction == SysParameterDirection.InputOutput)
                return QueryParameterDirection.InOut;

            throw new NotSupportedException();
        }
Exemple #35
0
 /// <summary>
 /// 存储过程的参数
 /// </summary>
 /// <param name="field">字段名</param>
 /// <param name="direction">参数方向</param>
 public Direction(string field, System.Data.ParameterDirection direction)
 {
     this._field = field;
     this._direction = direction;
 }