Esempio n. 1
0
 /// <include file='Doc/en_EN/FbParameter.xml' path='doc/class[@name="FbParameter"]/constrctor[@name="ctor(System.String,FbDbType,System.Int32)"]/*'/>
 public FbParameter(string parameterName, FbDbType fbType, int size) : this()
 {
     this.inferType     = false;
     this.parameterName = parameterName;
     this.fbType        = fbType;
     this.size          = size;
 }
Esempio n. 2
0
        /// <include file='Doc/en_EN/FbParameterCollection.xml'	path='doc/class[@name="FbParameterCollection"]/method[@name="Add(System.String,FbDbType,System.Int32,System.String)"]/*'/>
        public FbParameter Add(
            string parameterName, FbDbType fbType, int size, string sourceColumn)
        {
            FbParameter param = new FbParameter(parameterName, fbType, size, sourceColumn);

            return(this.Add(param));
        }
Esempio n. 3
0
        public static void SetParamValue(FbCommand fbCommand, string paramName, FbDbType paramType, object paramValue, object defaultValue = null)
        {
            if (defaultValue == null)
            {
                defaultValue = String.Empty;
            }

            if ((paramValue == null) || string.IsNullOrEmpty(paramValue.ToString()))
            {
                if (paramValue == null || string.IsNullOrEmpty(defaultValue.ToString()))
                {
                    fbCommand.Parameters.Add(paramName, DBNull.Value);
                }
                else
                {
                    fbCommand.Parameters.Add(paramName, defaultValue);
                }
            }
            else
            {
                if (((paramType == FbDbType.BigInt) || (paramType == FbDbType.Integer)) && (Convert.ToInt32(paramValue) < 1))
                {
                    fbCommand.Parameters.Add(paramName, DBNull.Value);
                }
                else
                {
                    fbCommand.Parameters.Add(paramName, paramType).Value = paramValue;
                }
            }
        }
Esempio n. 4
0
 public FbParameter(string parameterName, FbDbType fbType, int size)
     : this()
 {
     this.parameterName = parameterName;
     this.FbDbType      = fbType;
     this.Size          = size;
 }
Esempio n. 5
0
        private bool IncludedInWhereClause(DataRow schemaRow)
        {
            if (!(bool)schemaRow["IsKey"] &&
                (this.commandBuilderBehavior == FbCommandBuilderBehavior.KeyFields ||
                 this.commandBuilderBehavior == FbCommandBuilderBehavior.KeyAndTimestampFields))
            {
                if (this.timestampColumnName != schemaRow["BaseColumnName"].ToString())
                {
                    return(false);
                }
            }

            FbDbType dbType = (FbDbType)schemaRow["ProviderType"];

            if (dbType == FbDbType.Array || dbType == FbDbType.Binary)
            {
                return(false);
            }

            if ((bool)schemaRow["IsLong"])
            {
                return(false);
            }

            return(true);
        }
Esempio n. 6
0
        private short ValidateInputParameters()
        {
            short count = 0;

            for (int i = 0; i < this.parameters.Count; i++)
            {
                if (this.parameters[i].Direction == ParameterDirection.Input ||
                    this.parameters[i].Direction == ParameterDirection.InputOutput)
                {
                    FbDbType type = this.parameters[i].FbDbType;

                    if (type == FbDbType.Array || type == FbDbType.Decimal ||
                        type == FbDbType.Numeric)
                    {
                        return(-1);
                    }
                    else
                    {
                        count++;
                    }
                }
            }

            return(count);
        }
Esempio n. 7
0
 public FbParameter(string parameterName, FbDbType fbType, int size)
     : this()
 {
     this.parameterName = parameterName;
     this.FbDbType = fbType;
     this.Size = size;
 }
Esempio n. 8
0
        public FbParameter(
            string parameterName,
            FbDbType dbType,
            int size,
            ParameterDirection direction,
            bool isNullable,
            byte precision,
            byte scale,
            string sourceColumn,
#if !NETSTANDARD1_6
            DataRowVersion sourceVersion,
#endif
            object value)
        {
            ParameterName = parameterName;
            FbDbType      = dbType;
            Size          = size;
            _direction    = direction;
            _isNullable   = isNullable;
            _precision    = precision;
            _scale        = scale;
            _sourceColumn = sourceColumn;
#if !NETSTANDARD1_6
            _sourceVersion = sourceVersion;
#endif
            Value    = value;
            _charset = FbCharset.Default;
        }
Esempio n. 9
0
 public FbParameter(string parameterName, FbDbType fbType, int size, string sourceColumn)
     : this()
 {
     this.parameterName = parameterName;
     this.FbDbType      = fbType;
     this.Size          = size;
     this.sourceColumn  = sourceColumn;
 }
Esempio n. 10
0
 public FieldVO(string name, object valor, FbDbType type, int lenght, bool isFieldExist)
 {
     this.Name         = name;
     this.Value        = valor;
     this.Type         = type;
     this.Length       = lenght;
     this.IsFieldExist = isFieldExist;
 }
 private void SetFbDbType(object value)
 {
     if (value == null)
     {
         value = DBNull.Value;
     }
     _fbDbType = TypeHelper.GetFbDataTypeFromType(value.GetType());
 }
Esempio n. 12
0
 public FieldVO(string name, object value, FbDbType type, int length)
 {
     this.Name         = name;
     this.Value        = value;
     this.Type         = type;
     this.Length       = length;
     this.IsFieldExist = false;
 }
Esempio n. 13
0
 public TypeEntry(string fbTypeName, DbType dbType, FbDbType fbDbType, Type clrType, bool withLength, bool withPrecision)
 {
     FbTypeName    = fbTypeName;
     DbType        = dbType;
     FbDbType      = fbDbType;
     ClrType       = clrType;
     WithLength    = withLength;
     WithPrecision = withPrecision;
 }
Esempio n. 14
0
 public FbParameter()
 {
     this.fbDbType      = FbDbType.VarChar;
     this.direction     = ParameterDirection.Input;
     this.sourceVersion = DataRowVersion.Current;
     this.sourceColumn  = string.Empty;
     this.parameterName = string.Empty;
     this.charset       = FbCharset.Default;
 }
Esempio n. 15
0
 public TypeEntry(string fbTypeName, DbType dbType, FbDbType fbDbType, Type clrType, bool withLength, bool withPrecision)
 {
     FbTypeName = fbTypeName;
     DbType = dbType;
     FbDbType = fbDbType;
     ClrType = clrType;
     WithLength = withLength;
     WithPrecision = withPrecision;
 }
Esempio n. 16
0
 public FbParameter()
 {
     this.fbDbType = FbDbType.VarChar;
     this.direction = ParameterDirection.Input;
     this.sourceVersion = DataRowVersion.Current;
     this.sourceColumn = string.Empty;
     this.parameterName = string.Empty;
     this.charset = FbCharset.Default;
 }
Esempio n. 17
0
 public FbParameter()
 {
     _fbDbType              = FbDbType.VarChar;
     _direction             = ParameterDirection.Input;
     _sourceVersion         = DataRowVersion.Current;
     _sourceColumn          = string.Empty;
     _parameterName         = string.Empty;
     _charset               = FbCharset.Default;
     _internalParameterName = string.Empty;
 }
Esempio n. 18
0
        FbDbType GetFbDbType(DbColumnInfo column)
        {
            var dbtype  = column.DbTypeText;
            var isarray = dbtype.EndsWith("[]");

            if (isarray)
            {
                dbtype = dbtype.Remove(dbtype.Length - 2);
            }
            FbDbType ret = FbDbType.VarChar;

            switch (dbtype.ToLower().TrimStart('_'))
            {
            case "bigint": ret = FbDbType.BigInt; break;

            case "blob": ret = FbDbType.Binary; break;

            case "nchar":
            case "char":
            case "character": ret = FbDbType.Char; break;

            case "date": ret = FbDbType.Date; break;

            case "decimal": ret = FbDbType.Decimal; break;

            case "double":
            case "double precision": ret = FbDbType.Double; break;

            case "float": ret = FbDbType.Float; break;

            case "integer":
            case "int": ret = FbDbType.Integer; break;

            case "numeric":
            case "numeric precision": ret = FbDbType.Numeric; break;

            case "smallint": ret = FbDbType.SmallInt; break;

            case "time": ret = FbDbType.Time; break;

            case "timestamp": ret = FbDbType.TimeStamp; break;

            case "varchar":
            case "char varying":
            case "character varying": ret = FbDbType.VarChar; break;

            case "text": ret = FbDbType.Text; break;

            case "boolean": ret = FbDbType.Boolean; break;

            case "char(36)": ret = FbDbType.Guid; break;
            }
            return(isarray ? (ret | FbDbType.Array) : ret);
        }
        private FbParameter CreateInputParam(string paramName, FbDbType dbType, object objValue)
        {
            FbParameter param = new FbParameter(paramName, dbType);

            if (objValue == null)
            {
                objValue = string.Empty;
            }

            param.Value = objValue;

            return(param);
        }
Esempio n. 20
0
        /// <summary>
        /// Please refer to the documentation of <see cref="GentleSqlFactory"/> for details.
        /// </summary>
        public override long GetDbType(Type type)
        {
            FbDbType result = FbDbType.Integer;

            if (type.Equals(typeof(short)) || type.Equals(typeof(Boolean)))
            {
                result = FbDbType.SmallInt;
            }
            else if (type.Equals(typeof(int)) || type.IsEnum)
            {
                result = FbDbType.Integer;
            }
            else if (type.Equals(typeof(long)))
            {
                result = FbDbType.BigInt;
            }
            else if (type.Equals(typeof(double)) || type.Equals(typeof(Double)))
            {
                result = FbDbType.Double;
            }
            else if (type.Equals(typeof(float)) || type.Equals(typeof(Single)))
            {
                result = FbDbType.Float;
            }
            else if (type.Equals(typeof(decimal)) || type.Equals(typeof(Decimal)))
            {
                result = FbDbType.Decimal;
            }
            else if (type.Equals(typeof(DateTime)))
            {
                result = FbDbType.TimeStamp;
            }
            else if (type.Equals(typeof(char)))
            {
                result = FbDbType.Char;
            }
            else if (type.Equals(typeof(string)))
            {
                result = FbDbType.VarChar;
            }
            else
            {
                Check.Fail(Error.UnsupportedPropertyType, type.Name, provider.Name);
            }
            return((long)result);
        }
Esempio n. 21
0
 public void AddParam(FbCommand cmd, string campo, object valor, FbDbType fbDbType, int size = 0)
 {
     if (fbDbType == FbDbType.VarChar)
     {
         FbParameter p = new FbParameter(campo, FbDbType.VarChar, size, campo);
         p.Value = valor;
         cmd.Parameters.Add(p);
     }
     else if (fbDbType == FbDbType.Integer)
     {
         try
         {
             int?        val = (valor == null) ? null : (int?)Int32.Parse(valor.ToString());
             FbParameter p   = new FbParameter(campo, fbDbType);
             p.Value = val;
             cmd.Parameters.Add(p);
         }
         catch (Exception ex)
         {
             throw new Exception("O valor '" + valor + "' não é válido para o campo '" + campo + "'\n\nComando:\n" + cmd.CommandText, ex);
         }
     }
     else if (fbDbType == FbDbType.Decimal)
     {
         try
         {
             decimal?    val = (valor == null) ? null : (decimal?)Decimal.Parse(valor.ToString());
             FbParameter p   = new FbParameter(campo, fbDbType);
             p.Value = val;
             cmd.Parameters.Add(p);
         }
         catch (Exception ex)
         {
             throw new Exception("O valor '" + valor + "' não é válido para o campo '" + campo + "'\n\nComando:\n" + cmd.CommandText, ex);
         }
     }
     else
     {
         FbParameter p = new FbParameter(campo, fbDbType);
         p.Value = valor;
         cmd.Parameters.Add(p);
     }
 }
        /// <summary>
        /// Creates a SqlParameter given a name, type, and direction
        /// </summary>
        internal static FbParameter CreateSqlParameter(string name, TypeUsage type, ParameterMode mode, object value)
        {
            int?size;

            FbParameter result = new FbParameter(name, value);

            // .Direction
            ParameterDirection direction = MetadataHelpers.ParameterModeToParameterDirection(mode);

            if (result.Direction != direction)
            {
                result.Direction = direction;
            }

            // .Size and .SqlDbType
            // output parameters are handled differently (we need to ensure there is space for return
            // values where the user has not given a specific Size/MaxLength)
            bool     isOutParam = mode != ParameterMode.In;
            FbDbType sqlDbType  = GetSqlDbType(type, isOutParam, out size);

            if (result.FbDbType != sqlDbType)
            {
                result.FbDbType = sqlDbType;
            }

            // Note that we overwrite 'facet' parameters where either the value is different or
            // there is an output parameter.
            if (size.HasValue && (isOutParam || result.Size != size.Value))
            {
                result.Size = size.Value;
            }

            // .IsNullable
            bool isNullable = MetadataHelpers.IsNullable(type);

            if (isOutParam || isNullable != result.IsNullable)
            {
                result.IsNullable = isNullable;
            }

            return(result);
        }
Esempio n. 23
0
 public FbParameter(
     string parameterName,
     FbDbType dbType,
     int size,
     ParameterDirection direction,
     bool isNullable,
     byte precision,
     byte scale,
     string sourceColumn,
     DataRowVersion sourceVersion,
     object value)
 {
     this.parameterName = parameterName;
     this.FbDbType      = dbType;
     this.Size          = size;
     this.direction     = direction;
     this.isNullable    = isNullable;
     this.precision     = precision;
     this.scale         = scale;
     this.sourceColumn  = sourceColumn;
     this.sourceVersion = sourceVersion;
     this.Value         = value;
     this.charset       = FbCharset.Default;
 }
Esempio n. 24
0
 public FbParameter(
     string parameterName,
     FbDbType dbType,
     int size,
     ParameterDirection direction,
     bool isNullable,
     byte precision,
     byte scale,
     string sourceColumn,
     DataRowVersion sourceVersion,
     object value)
 {
     this.inferType     = false;
     this.parameterName = parameterName;
     this.fbType        = dbType;
     this.size          = size;
     this.direction     = direction;
     this.isNullable    = isNullable;
     this.precision     = precision;
     this.scale         = scale;
     this.sourceColumn  = sourceColumn;
     this.sourceVersion = sourceVersion;
     this.value         = value;
 }
Esempio n. 25
0
		private FbParameter CreateInputParam(string paramName, FbDbType dbType, object objValue)
		{
			FbParameter param = new FbParameter(paramName, dbType);

			if (objValue == null)
			{
				objValue = string.Empty;
			}

			param.Value = objValue;

			return param;
		}
Esempio n. 26
0
 public FbParameter(string parameterName, FbDbType fbType)
     : this()
 {
     this.parameterName = parameterName;
     this.FbDbType      = fbType;
 }
 public FbDateTimeTypeMapping(string storeType, FbDbType fbDbType)
     : base(storeType)
     => _fbDbType = fbDbType;
Esempio n. 28
0
        /// <include file='Doc/en_EN/FbParameterCollection.xml'	path='doc/class[@name="FbParameterCollection"]/method[@name="Add(System.String,FbDbType)"]/*'/>
        public FbParameter Add(string parameterName, FbDbType type)
        {
            FbParameter param = new FbParameter(parameterName, type);

            return(this.Add(param));
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="SettingsPropertyColumn"/> class.
 /// </summary>
 /// <param name="settings">
 /// The settings.
 /// </param>
 /// <param name="dataType">
 /// The data type.
 /// </param>
 /// <param name="size">
 /// The size.
 /// </param>
 public FbSettingsPropertyColumn(SettingsProperty settings, FbDbType dataType, int size)
 {
     this.DataType = dataType;
       this.Settings = settings;
       this.Size = size;
 }
 public FbParameter Add(string parameterName, FbDbType fbType, int size)
 {
     return this.Add(new FbParameter(parameterName, fbType, size));
 }
 public FbParameter Add(string parameterName, FbDbType fbType, int size, string sourceColumn)
 {
     return(Add(new FbParameter(parameterName, fbType, size, sourceColumn)));
 }
		/// <include file='Doc/en_EN/FbParameter.xml' path='doc/class[@name="FbParameter"]/constrctor[@name="ctor(System.String,FbDbType,System.Int32)"]/*'/>
		public FbParameter(string parameterName, FbDbType fbType, int size) : this()
		{
			this.inferType		= false;
			this.parameterName	= parameterName;
			this.fbType			= fbType;
			this.size			= size;
		}
        /// <summary>
        /// The add profile column.
        /// </summary>
        /// <param name="name">
        /// The name.
        /// </param>
        /// <param name="columnType">
        /// The column type.
        /// </param>
        /// <param name="size">
        /// The size.
        /// </param>
        public static void AddProfileColumn( [NotNull] string name, FbDbType columnType, int size)
        {
            // get column type...
            string type = columnType.ToString();

            if (size > 0)
            {
                type += "(" + size + ")";
            }

            string sql = "ALTER TABLE {0} ADD {1} {2} ".FormatWith(
              MsSqlDbAccess.GetObjectName("UserProfile"), name, type);

            using (var cmd = MsSqlDbAccess.GetCommand(sql, true))
            {
                cmd.CommandType = CommandType.Text;
                MsSqlDbAccess.Current.ExecuteNonQuery(cmd);
            }
        }
Esempio n. 34
0
        public static FbParameter SetValue(this DbParameterCollection parameters, string parameterName, FbDbType dbType, FbCharset charset, int size)
        {
            var param = new FbParameter {
                ParameterName = parameterName, FbDbType = dbType, Charset = charset, Size = size
            };

            if (parameters.Contains(parameterName))
            {
                parameters.RemoveAt(parameterName);
            }

            parameters.Add(param);
            return(param);
        }
Esempio n. 35
0
        private void SetFbDbType(object value)
        {
            if (value == null)
            {
                value = System.DBNull.Value;
            }

            TypeCode code = Type.GetTypeCode(value.GetType());

            switch (code)
            {
            case TypeCode.Char:
                this.fbDbType = FbDbType.Char;
                break;

            case TypeCode.DBNull:
            case TypeCode.String:
                this.fbDbType = FbDbType.VarChar;
                break;

            case TypeCode.Boolean:
                this.fbDbType = FbDbType.Boolean;
                break;

            case TypeCode.Byte:
            case TypeCode.SByte:
            case TypeCode.Int16:
            case TypeCode.UInt16:
                this.fbDbType = FbDbType.SmallInt;
                break;

            case TypeCode.Int32:
            case TypeCode.UInt32:
                this.fbDbType = FbDbType.Integer;
                break;

            case TypeCode.Int64:
            case TypeCode.UInt64:
                this.fbDbType = FbDbType.BigInt;
                break;

            case TypeCode.Single:
                this.fbDbType = FbDbType.Float;
                break;

            case TypeCode.Double:
                this.fbDbType = FbDbType.Double;
                break;

            case TypeCode.Decimal:
                this.fbDbType = FbDbType.Decimal;
                break;

            case TypeCode.DateTime:
                this.fbDbType = FbDbType.TimeStamp;
                break;

            case TypeCode.Empty:
            default:
                if (value is Guid)
                {
                    this.fbDbType = FbDbType.Guid;
                }
                else if (code == TypeCode.Object)
                {
                    this.fbDbType = FbDbType.Binary;
                }
                else
                {
                    throw new SystemException("Value is of unknown data type");
                }
                break;
            }
        }
Esempio n. 36
0
        public static FbParameter SetValue(this DbParameterCollection parameters, string parameterName, FbDbType dbType)
        {
            var param = new FbParameter { ParameterName = parameterName, FbDbType = dbType };
            if (parameters.Contains(parameterName))
                parameters.RemoveAt(parameterName);

            parameters.Add(param);
            return param;
        }
Esempio n. 37
0
 public static Term DbScalarToTerm(object scalar, FbDbType dbType, FType fType, string dbEntity)
 {
     switch (dbType)
       {
     case FbDbType.SmallInt:
     case FbDbType.Decimal:
     case FbDbType.Integer:
     case FbDbType.Float:
     case FbDbType.Numeric:
     case FbDbType.Double:
     case FbDbType.BigInt:
       return new Term (scalar.ToString (), FType.number);
     case FbDbType.Char:
     case FbDbType.VarChar:
       return new Term (Utils.AtomFromVarChar (scalar.ToString ()), FType.atom);
     case FbDbType.Date:
     case FbDbType.TimeStamp:
       return new Term (Convert.ToDateTime (scalar));
     case FbDbType.Time:
       return new Term ((Convert.ToDateTime (scalar)).TimeOfDay);
     default:
       IO.Error ("Firebird data type {0} in table/view/stored procedure {1} not supported in Prolog", dbType, dbEntity);
       return null;
       }
 }
        private bool GetDbTypeAndSizeFromString( string providerData, out FbDbType dbType, out int size )
        {
            size = -1;
            dbType = FbDbType.VarChar;

            if ( String.IsNullOrEmpty( providerData ) )
            {
                return false;
            }

            // split the data
            string [] chunk = providerData.Split( new char [] { ';' } );

            // first item is the column name...
            string columnName = chunk [0];
            // vzrus: here we replace MS SQL data types
            if (chunk[1].IndexOf("varchar") >= 0 || chunk[1].IndexOf("nvarchar") >= 0)
            { chunk[1] = "VarChar"; }
            if (chunk[1].IndexOf("int") >= 0)
            { chunk[1] = "Integer"; }
            if (chunk[1].IndexOf("DateTime") >= 0)
            { chunk[1] = "TimeStamp"; }
            if (chunk[1].IndexOf("bit") >= 0)
            { chunk[1] = "Boolean"; }

            // get the datatype and ignore case...
            dbType = ( FbDbType )Enum.Parse(typeof( FbDbType ), chunk [1], true );

            if ( chunk.Length > 2 )
            {
                // handle size...
                if ( !Int32.TryParse( chunk [2], out size ) )
                {
                    throw new ArgumentException( "Unable to parse as integer: " + chunk [2] );
                }
            }

            return true;
        }
		public FbParameter()
		{
			_fbDbType = FbDbType.VarChar;
			_direction = ParameterDirection.Input;
			_sourceVersion = DataRowVersion.Current;
			_sourceColumn = string.Empty;
			_parameterName = string.Empty;
			_charset = FbCharset.Default;
			_internalParameterName = string.Empty;
		}
		/// <include file='Doc/en_EN/FbParameter.xml' path='doc/class[@name="FbParameter"]/constrctor[@name="ctor(System.String,FbDbType,System.Int32,System.String)"]/*'/>
		public FbParameter(string parameterName, FbDbType fbType, int size, string sourceColumn)
			: this()
		{
			this.inferType		= false;
			this.parameterName	= parameterName;
			this.fbType			= fbType;
			this.size			= size;
			this.sourceColumn	= sourceColumn;
		}
 public FbParameter Add(string parameterName, FbDbType type)
 {
     return this.Add(new FbParameter(parameterName, type));
 }
		public FbParameter(
			string				parameterName, 
			FbDbType			dbType, 
			int					size,
			ParameterDirection	direction,
			bool				isNullable,
			byte				precision,
			byte				scale,
			string				sourceColumn,
			DataRowVersion		sourceVersion,
			object				value)
		{
			this.inferType		= false;
			this.parameterName	= parameterName;
			this.fbType			= dbType;
			this.size			= size;
			this.direction		= direction;
			this.isNullable		= isNullable;
			this.precision		= precision;
			this.scale			= scale;
			this.sourceColumn	= sourceColumn;
			this.sourceVersion	= sourceVersion;
			this.value			= value;
		}
 public FbParameter Add(string parameterName, FbDbType fbType, int size, string sourceColumn)
 {
     return this.Add(new FbParameter(parameterName, fbType, size, sourceColumn));
 }
		private void SetFbDbType(object value)
		{
			if (value == null)
			{
				value = System.DBNull.Value;
			}

			TypeCode code = Type.GetTypeCode(value.GetType());

			switch (code)
			{
				case TypeCode.Object:
					this.fbType = FbDbType.Binary;
					break;

				case TypeCode.Char:
					this.fbType = FbDbType.Char;
					break;

				case TypeCode.DBNull:
				case TypeCode.String:
					this.fbType = FbDbType.VarChar;
					break;

				case TypeCode.Boolean:
				case TypeCode.Byte:
				case TypeCode.SByte:
				case TypeCode.Int16:
				case TypeCode.UInt16:
					this.fbType = FbDbType.SmallInt;
					break;

				case TypeCode.Int32:
				case TypeCode.UInt32:
					this.fbType = FbDbType.Integer;
					break;

				case TypeCode.Int64:
				case TypeCode.UInt64:
					this.fbType = FbDbType.BigInt;
					break;

				case TypeCode.Single:
					this.fbType = FbDbType.Float;
					break;

				case TypeCode.Double:
					this.fbType = FbDbType.Double;
					break;

				case TypeCode.Decimal:
					this.fbType = FbDbType.Decimal;
					break;

				case TypeCode.DateTime:
					this.fbType = FbDbType.TimeStamp;
					break;

				case TypeCode.Empty:
				default:
					if (value is Guid)
					{
						this.fbType = FbDbType.Guid;
					}
					else
					{
						throw new SystemException("Value is of unknown data type");
					}
					break;
			}
		}
Esempio n. 45
0
        private void SetFbDbType(object value)
        {
            if (value == null)
            {
                value = DBNull.Value;
            }

            var code = Type.GetTypeCode(value.GetType());

            switch (code)
            {
            case TypeCode.Char:
                _fbDbType = FbDbType.Char;
                break;

            case TypeCode.DBNull:
            case TypeCode.String:
                _fbDbType = FbDbType.VarChar;
                break;

            case TypeCode.Boolean:
                _fbDbType = FbDbType.Boolean;
                break;

            case TypeCode.Byte:
            case TypeCode.SByte:
            case TypeCode.Int16:
            case TypeCode.UInt16:
                _fbDbType = FbDbType.SmallInt;
                break;

            case TypeCode.Int32:
            case TypeCode.UInt32:
                _fbDbType = FbDbType.Integer;
                break;

            case TypeCode.Int64:
            case TypeCode.UInt64:
                _fbDbType = FbDbType.BigInt;
                break;

            case TypeCode.Single:
                _fbDbType = FbDbType.Float;
                break;

            case TypeCode.Double:
                _fbDbType = FbDbType.Double;
                break;

            case TypeCode.Decimal:
                _fbDbType = FbDbType.Decimal;
                break;

            case TypeCode.DateTime:
                _fbDbType = FbDbType.TimeStamp;
                break;

            case TypeCode.Empty:
            default:
                if (value is Guid)
                {
                    _fbDbType = FbDbType.Guid;
                }
                else if (code == TypeCode.Object)
                {
                    _fbDbType = FbDbType.Binary;
                }
                else
                {
                    throw new ArgumentException("Parameter type is unknown.");
                }
                break;
            }
        }
Esempio n. 46
0
 public TableColumn(string nm, FbDbType dt, int sz, int pr, int sc, bool nu)
     : base(nm, dt, sz, pr, sc)
 {
     isNullable = nu;
 }
		/// <include file='Doc/en_EN/FbParameterCollection.xml'	path='doc/class[@name="FbParameterCollection"]/method[@name="Add(System.String,FbDbType,System.Int32)"]/*'/>
		public FbParameter Add(string parameterName, FbDbType fbType, int size)
		{
			FbParameter param = new FbParameter(parameterName, fbType, size);

			return this.Add(param);
		}
Esempio n. 48
0
 public ProcParam(string nm, FbDbType dt, int sz, int pr, int sc, ParameterDirection pd)
     : base(nm, dt, sz, pr, sc)
 {
     direction = pd;
 }
		/// <include file='Doc/en_EN/FbParameterCollection.xml'	path='doc/class[@name="FbParameterCollection"]/method[@name="Add(System.String,FbDbType)"]/*'/>
		public FbParameter Add(string parameterName, FbDbType type)
		{
			FbParameter param = new FbParameter(parameterName, type);

			return this.Add(param);
		}
Esempio n. 50
0
 public DbDataItem(string nm, FbDbType dt, int sz, int pr, int sc)
 {
     name       = nm;
       dbType     = dt;
       size       = sz;
       precision  = pr;
       scale      = sc;
 }
Esempio n. 51
0
        public void AddProfileColumn( string Name, FbDbType columnType, int size)
        {
            // get column type...
            string type = columnType.ToString();
               // FbDbType.SmallInt
               // FbDbType.TimeStamp
              //  FbDbType.VarChar
              //  FbDbType.Integer

            if (type.ToLower()=="timestamp")
            { type = "TimeStamp"; }

            if ( size > 0 )
            {
                type += "(" + size.ToString() + ")";
            }
            if ( type.Contains("VarChar") && MsSqlDbAccess.DatabaseEncoding !=null)
            {
                type += " CHARACTER SET " + MsSqlDbAccess.DatabaseEncoding;

                      if (MsSqlDbAccess.DatabaseCollation !=null)
                  {
                      type += " COLLATE " +  MsSqlDbAccess.DatabaseCollation;
                  }
            }

            string sql = String.Format(@"ALTER TABLE {0} ADD {1}  {2};", MsSqlDbAccess.GetObjectName("P_profile"), Name, type);

            using ( FbCommand cmd = new FbCommand( sql ) )
            {
                cmd.CommandType = CommandType.Text;
                _dbAccess.ExecuteNonQuery(cmd );
            }
        }
		public FbParameter(string parameterName, FbDbType fbType, int size, string sourceColumn)
			: this()
		{
			ParameterName = parameterName;
			FbDbType = fbType;
			Size = size;
			_sourceColumn = sourceColumn;
		}
Esempio n. 53
0
		public FbParameter(string parameterName, FbDbType fbType)
			: this()
		{
			this.parameterName = parameterName;
			this.FbDbType = fbType;
		}
Esempio n. 54
0
 public void SetParameters(string column, FbDbType fbdbtype, object value)
 {
     cmd.Parameters.Add(column, fbdbtype).Value = value;
 }
Esempio n. 55
0
        protected override DataTable ProcessResult(DataTable schema)
        {
            schema.BeginLoadData();
            schema.Columns.Add("IS_NULLABLE", typeof(bool));
            schema.Columns.Add("IS_ARRAY", typeof(bool));

            foreach (DataRow row in schema.Rows)
            {
                int blrType = Convert.ToInt32(row["FIELD_TYPE"], CultureInfo.InvariantCulture);

                int subType = 0;
                if (row["COLUMN_SUB_TYPE"] != System.DBNull.Value)
                {
                    subType = Convert.ToInt32(row["COLUMN_SUB_TYPE"], CultureInfo.InvariantCulture);
                }

                int scale = 0;
                if (row["NUMERIC_SCALE"] != System.DBNull.Value)
                {
                    scale = Convert.ToInt32(row["NUMERIC_SCALE"], CultureInfo.InvariantCulture);
                }

                row["IS_NULLABLE"] = (row["COLUMN_NULLABLE"] == DBNull.Value);
                row["IS_ARRAY"]    = (row["COLUMN_ARRAY"] != DBNull.Value);

                FbDbType dbType = (FbDbType)TypeHelper.GetDbDataType(blrType, subType, scale);
                row["COLUMN_DATA_TYPE"] = TypeHelper.GetDataTypeName((DbDataType)dbType).ToLower(CultureInfo.InvariantCulture);

                if (dbType == FbDbType.Char || dbType == FbDbType.VarChar)
                {
                    if (!row.IsNull("CHARACTER_MAX_LENGTH"))
                    {
                        row["COLUMN_SIZE"] = row["CHARACTER_MAX_LENGTH"];
                    }
                }
                else
                {
                    row["CHARACTER_OCTET_LENGTH"] = 0;
                }

                if (dbType == FbDbType.Binary || dbType == FbDbType.Text)
                {
                    row["COLUMN_SIZE"] = Int32.MaxValue;
                }

                if (row["NUMERIC_PRECISION"] == System.DBNull.Value)
                {
                    row["NUMERIC_PRECISION"] = 0;
                }

                if ((dbType == FbDbType.Decimal || dbType == FbDbType.Numeric) &&
                    (row["NUMERIC_PRECISION"] == System.DBNull.Value || Convert.ToInt32(row["NUMERIC_PRECISION"]) == 0))
                {
                    row["NUMERIC_PRECISION"] = row["COLUMN_SIZE"];
                }

                row["NUMERIC_SCALE"] = (-1) * scale;
            }

            schema.EndLoadData();
            schema.AcceptChanges();

            // Remove not more needed columns
            schema.Columns.Remove("COLUMN_NULLABLE");
            schema.Columns.Remove("COLUMN_ARRAY");
            schema.Columns.Remove("FIELD_TYPE");
            schema.Columns.Remove("CHARACTER_MAX_LENGTH");

            return(schema);
        }
Esempio n. 56
0
		public FbParameter(
			string parameterName,
			FbDbType dbType,
			int size,
			ParameterDirection direction,
			bool isNullable,
			byte precision,
			byte scale,
			string sourceColumn,
			DataRowVersion sourceVersion,
			object value)
		{
			this.parameterName = parameterName;
			this.FbDbType = dbType;
			this.Size = size;
			this.direction = direction;
			this.isNullable = isNullable;
			this.precision = precision;
			this.scale = scale;
			this.sourceColumn = sourceColumn;
			this.sourceVersion = sourceVersion;
			this.Value = value;
			this.charset = FbCharset.Default;
		}
Esempio n. 57
0
 public FbStringTypeMapping(string storeType, FbDbType fbDbType, int?size = null)
     : base(storeType, unicode: true, size: size)
 {
     _fbDbType = fbDbType;
 }
        /// <summary>
        /// The get db type and size from string.
        /// </summary>
        /// <param name="providerData">
        /// The provider data.
        /// </param>
        /// <param name="dbType">
        /// The db type.
        /// </param>
        /// <param name="size">
        /// The size.
        /// </param>
        /// <returns>
        /// The get db type and size from string.
        /// </returns>
        /// <exception cref="ArgumentException">
        /// </exception>
        private static bool GetDbTypeAndSizeFromString(string providerData, out FbDbType dbType, out int size)
        {
            size = -1;
            dbType = FbDbType.VarChar;

            if (providerData.IsNotSet())
            {
                return false;
            }

            // split the data
            string[] chunk = providerData.Split(new[] { ';' });

            // first item is the column name...
            string columnName = chunk[0];
            // vzrus addon convert values from mssql types...
            if (chunk[1].IndexOf("varchar") >= 0)
            { chunk[1] = "VarChar"; }
            if (chunk[1].IndexOf("int") >= 0)
            { chunk[1] = "Integer"; }
            if (chunk[1].IndexOf("DateTime") >= 0)
            { chunk[1] = "TimeStamp"; }

            // get the datatype and ignore case...
            dbType = (FbDbType)Enum.Parse(typeof(FbDbType), chunk[1], true);

            if (chunk.Length > 2)
            {
                // handle size...
                if (!Int32.TryParse(chunk[2], out size))
                {
                    throw new ArgumentException("Unable to parse as integer: " + chunk[2]);
                }
            }

            return true;
        }