protected override void AddParameter(DbCommand command, QueryParameter parameter, object value)
        {
            DbQueryType sqlType = (DbQueryType)parameter.QueryType;

            if (sqlType == null)
            {
                sqlType = (DbQueryType)this.Provider.Language.TypeSystem.GetColumnType(parameter.Type);
            }
            int len = sqlType.Length;

            if (len == 0 && DbTypeSystem.IsVariableLength(sqlType.SqlDbType))
            {
                len = Int32.MaxValue;
            }
            //var p = ((OracleCommand)command).Parameters.Add(":" + parameter.Name, ToOracleType(sqlType.SqlDbType), len);
            var p = provider.AdoProvider.CreateParameter(":" + parameter.Name, sqlType.SqlDbType, len);

            /*
             * if (sqlType.Precision != 0)
             *  p.Precision = (byte)sqlType.Precision;
             * if (sqlType.Scale != 0)
             *  p.Scale = (byte)sqlType.Scale;
             */
            p.Value = value ?? DBNull.Value;
            command.Parameters.Add(p);
        }
Exemple #2
0
            protected override void AddParameter(DbCommand command, QueryParameter parameter, object value)
            {
                DbQueryType sqlType = (DbQueryType)parameter.QueryType;

                if (sqlType == null)
                {
                    sqlType = (DbQueryType)this.Provider.Language.TypeSystem.GetColumnType(parameter.Type);
                }
                int len = sqlType.Length;

                if (len == 0 && DbTypeSystem.IsVariableLength(sqlType.SqlDbType))
                {
                    len = Int32.MaxValue;
                }
                var p = ((SqlCommand)command).Parameters.Add("@" + parameter.Name, sqlType.SqlDbType, len);

                if (sqlType.Precision != 0)
                {
                    p.Precision = (byte)sqlType.Precision;
                }
                if (sqlType.Scale != 0)
                {
                    p.Scale = (byte)sqlType.Scale;
                }
                p.Value = value ?? DBNull.Value;
            }
Exemple #3
0
            protected override void AddParameter(DbCommand command, QueryParameter parameter, object value)
            {
                DbQueryType queryType = (DbQueryType)parameter.QueryType;

                if (queryType == null)
                {
                    queryType = (DbQueryType)base.Provider.Language.TypeSystem.GetColumnType(parameter.Type);
                }
                int length = queryType.Length;

                if ((length == 0) && DbTypeSystem.IsVariableLength(queryType.SqlDbType))
                {
                    length = 0x7fffffff;
                }
                if (queryType.SqlDbType == SqlDbType.NVarChar)
                {
                    length = System.Convert.ToString(value).Length;
                }
                SqlParameter parameter2 = ((SqlCommand)command).Parameters.Add("@" + parameter.Name, queryType.SqlDbType, length);

                if (queryType.Precision != 0)
                {
                    parameter2.Precision = (byte)queryType.Precision;
                }
                if (queryType.Scale != 0)
                {
                    parameter2.Scale = (byte)queryType.Scale;
                }
                parameter2.Value = value ?? DBNull.Value;
            }
            protected override OleDbType GetOleDbType(QueryType type)
            {
                DbQueryType sqlType = type as DbQueryType;

                if (sqlType != null)
                {
                    return(ToOleDbType(sqlType.SqlDbType));
                }
                return(base.GetOleDbType(type));
            }
Exemple #5
0
            protected OleDbType GetOleDbType(QueryType type)
            {
                DbQueryType sqlType = type as DbQueryType;

                if (sqlType != null)
                {
                    return(ToOleDbType(sqlType.SqlDbType));
                }

                return(ToOleDbType(((DbQueryType)type).SqlDbType));
            }
        protected override void AddParameter(DbCommand command, QueryParameter parameter, object value)
        {
            DbQueryType queryType = (DbQueryType)parameter.QueryType;

            if (queryType == null)
            {
                queryType = (DbQueryType)base.Provider.Language.TypeSystem.GetColumnType(parameter.Type);
            }
            int length = queryType.Length;

            if ((length == 0) && DbTypeSystem.IsVariableLength(queryType.SqlDbType))
            {
                length = 0x7fffffff;
            }
            DbParameter parameter2 = this.provider.AdoProvider.CreateParameter(":" + parameter.Name, queryType.SqlDbType, length);

            parameter2.Value = value ?? DBNull.Value;
            command.Parameters.Add(parameter2);
        }
Exemple #7
0
            protected override void AddParameter(DbCommand command, QueryParameter parameter, object value)
            {
                DbQueryType sqlType = (DbQueryType)parameter.QueryType;

                if (sqlType == null)
                {
                    sqlType = (DbQueryType)this.provider.Language.TypeSystem.GetColumnType(parameter.Type);
                }
                var p = ((MySqlCommand)command).Parameters.Add(parameter.Name, ToMySqlDbType(sqlType.SqlDbType), sqlType.Length);

                if (sqlType.Precision != 0)
                {
                    p.Precision = (byte)sqlType.Precision;
                }
                if (sqlType.Scale != 0)
                {
                    p.Scale = (byte)sqlType.Scale;
                }
                p.Value = value ?? DBNull.Value;
            }
Exemple #8
0
 public VfpDbQueryType(DbQueryType queryType)
     : base(queryType.SqlDbType, queryType.NotNull, queryType.Length, queryType.Precision, queryType.Scale)
 {
 }
        string GetVariableDeclaration(QueryType type, bool suppressSize)
        {
            StringBuilder sb        = new StringBuilder();
            DbQueryType   sqlType   = (DbQueryType)type;
            SqlDbType     sqlDbType = sqlType.SqlDbType;

            switch (sqlDbType)
            {
            case SqlDbType.BigInt:
            case SqlDbType.Bit:
            case SqlDbType.DateTime:
            case SqlDbType.Int:
            case SqlDbType.Money:
            case SqlDbType.SmallDateTime:
            case SqlDbType.SmallInt:
            case SqlDbType.SmallMoney:
            case SqlDbType.Timestamp:
            case SqlDbType.TinyInt:
            case SqlDbType.UniqueIdentifier:
            case SqlDbType.Variant:
            case SqlDbType.Xml:
                sb.Append(sqlDbType);
                break;

            case SqlDbType.Binary:
            case SqlDbType.Char:
            case SqlDbType.NChar:
                sb.Append(sqlDbType);
                if (type.Length > 0 && !suppressSize)
                {
                    sb.Append("(");
                    sb.Append(type.Length);
                    sb.Append(")");
                }

                break;

            case SqlDbType.Image:
            case SqlDbType.NText:
            case SqlDbType.NVarChar:
            case SqlDbType.Text:
            case SqlDbType.VarBinary:
            case SqlDbType.VarChar:
                sb.Append(sqlDbType);
                if (type.Length > 0 && !suppressSize)
                {
                    sb.Append("(");
                    sb.Append(type.Length);
                    sb.Append(")");
                }

                break;

            case SqlDbType.Decimal:
                sb.Append("Currency");
                break;

            case SqlDbType.Float:
            case SqlDbType.Real:
                sb.Append(sqlDbType);
                if (type.Precision != 0)
                {
                    sb.Append("(");
                    sb.Append(type.Precision);
                    if (type.Scale != 0)
                    {
                        sb.Append(",");
                        sb.Append(type.Scale);
                    }

                    sb.Append(")");
                }

                break;
            }

            return(sb.ToString());
        }
Exemple #10
0
        public override string GetVariableDeclaration(QueryType type, bool suppressSize)
        {
            StringBuilder sb        = new StringBuilder();
            DbQueryType   sqlType   = (DbQueryType)type;
            SqlDbType     sqlDbType = sqlType.SqlDbType;

            switch (sqlDbType)
            {
            case SqlDbType.BigInt:
            case SqlDbType.SmallInt:
            case SqlDbType.Int:
            case SqlDbType.TinyInt:
                sb.Append("INTEGER");
                break;

            case SqlDbType.Bit:
                sb.Append("BOOLEAN");
                break;

            case SqlDbType.SmallDateTime:
                sb.Append("DATETIME");
                break;

            case SqlDbType.Char:
            case SqlDbType.NChar:
                sb.Append("CHAR");
                if (type.Length > 0 && !suppressSize)
                {
                    sb.Append("(");
                    sb.Append(type.Length);
                    sb.Append(")");
                }
                break;

            case SqlDbType.Variant:
            case SqlDbType.Binary:
            case SqlDbType.Image:
            case SqlDbType.UniqueIdentifier:     //There is a setting to make it string, look at later
                sb.Append("BLOB");
                if (type.Length > 0 && !suppressSize)
                {
                    sb.Append("(");
                    sb.Append(type.Length);
                    sb.Append(")");
                }
                break;

            case SqlDbType.Xml:
            case SqlDbType.NText:
            case SqlDbType.NVarChar:
            case SqlDbType.Text:
            case SqlDbType.VarBinary:
            case SqlDbType.VarChar:
                sb.Append("TEXT");
                if (type.Length > 0 && !suppressSize)
                {
                    sb.Append("(");
                    sb.Append(type.Length);
                    sb.Append(")");
                }
                break;

            case SqlDbType.Decimal:
            case SqlDbType.Money:
            case SqlDbType.SmallMoney:
                sb.Append("NUMERIC");
                if (type.Precision != 0)
                {
                    sb.Append("(");
                    sb.Append(type.Precision);
                    sb.Append(")");
                }
                break;

            case SqlDbType.Float:
            case SqlDbType.Real:
                sb.Append("FLOAT");
                if (type.Precision != 0)
                {
                    sb.Append("(");
                    sb.Append(type.Precision);
                    sb.Append(")");
                }
                break;

            case SqlDbType.Date:
            case SqlDbType.DateTime:
            case SqlDbType.Timestamp:
            default:
                sb.Append(sqlDbType);
                break;
            }
            return(sb.ToString());
        }
		public QueryParameter(string name, Type type, DbQueryType queryType)
		{
			this.Name = name;
			this.Type = type;
			this.QueryType = queryType;
		}