Exemplo n.º 1
0
        public void Add(OdbcType type, Object objValue)
        {
            OdbcParameter parm = new OdbcParameter(type.ToString(), type);

            parm.Value = objValue;
            this.Add(parm);
        }
Exemplo n.º 2
0
        /// <summary>
        /// todoComment
        /// </summary>
        /// <param name="ADBFieldName"></param>
        /// <param name="ADataRow"></param>
        /// <param name="ACriteriaField"></param>
        /// <param name="AMatchField"></param>
        /// <param name="AOdbcType"></param>
        /// <param name="AOdbcSize"></param>
        /// <param name="AWhereClause"></param>
        /// <param name="AIntParamArray"></param>
        public TDynamicSearchHelper(String ADBFieldName,
                                    DataRow ADataRow,
                                    String ACriteriaField,
                                    String AMatchField,
                                    OdbcType AOdbcType,
                                    Int32 AOdbcSize,
                                    ref String AWhereClause,
                                    ref ArrayList AIntParamArray)
        {
            object        ParameterValue;
            OdbcParameter miParam;

            FDBFieldName   = ADBFieldName;
            FDataRow       = ADataRow;
            FCriteriaField = ACriteriaField;
            FMatchField    = AMatchField;

            ParameterValue = GetParameterValue();

            if (ParameterValue.ToString() != String.Empty)
            {
                miParam       = new OdbcParameter("", AOdbcType, AOdbcSize);
                miParam.Value = ParameterValue;

                AIntParamArray.Add(miParam);
                AWhereClause = AWhereClause + GetWhereString();
            }
        }
Exemplo n.º 3
0
    protected override Type?ToClrType(OdbcType dbType, bool isNullable, int?maxLength)
    {
        switch (dbType)
        {
        case OdbcType.BigInt:
            return(isNullable ? typeof(long?) : typeof(long));

        case OdbcType.Binary:
            return(typeof(byte[]));

        case OdbcType.Bit:
            return(isNullable ? typeof(bool?) : typeof(bool));

        case OdbcType.NChar:
        case OdbcType.NVarChar:
        case OdbcType.Char:
        case OdbcType.VarChar:
            return((maxLength == 1) ?
                   (isNullable ? typeof(char?) : typeof(char))
                                : typeof(string));

        case OdbcType.Decimal:
        case OdbcType.Numeric:
            return(isNullable ? typeof(decimal?) : typeof(decimal));

        case OdbcType.Double:
            return(isNullable ? typeof(double?) : typeof(double));

        case OdbcType.Int:
            return(isNullable ? typeof(int?) : typeof(int));

        case OdbcType.Text:
        case OdbcType.NText:
            return(typeof(string));

        case OdbcType.Real:
            return(isNullable ? typeof(float?) : typeof(float));

        case OdbcType.UniqueIdentifier:
            return(isNullable ? typeof(Guid?) : typeof(Guid));

        case OdbcType.SmallInt:
            return(isNullable ? typeof(ushort?) : typeof(ushort));

        case OdbcType.TinyInt:
            return(isNullable ? typeof(byte?) : typeof(byte));

        case OdbcType.VarBinary:
        case OdbcType.Image:
        case OdbcType.Timestamp:
            return(typeof(byte[]));

        case OdbcType.Date:
        case OdbcType.DateTime:
        case OdbcType.SmallDateTime:
        case OdbcType.Time:
            return(typeof(DateTime));
        }
        return(null);
    }
Exemplo n.º 4
0
        OdbcType GetOdbcType(DbColumnInfo column)
        {
            var      dbtype = column.DbTypeText;
            OdbcType ret    = OdbcType.VarChar;

            switch (dbtype?.ToLower().TrimStart('_'))
            {
            case "int8":
            case "serial8":
            case "bigserial":
            case "bigint": ret = OdbcType.BigInt; break;

            case "byte":
            case "blob": ret = OdbcType.VarBinary; break;

            case "nchar": ret = OdbcType.NChar; break;

            case "char":
            case "character": ret = OdbcType.Char; break;

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

            case "dec":
            case "decimal": ret = OdbcType.Decimal; break;

            case "double":
            case "double precision":
            case "float": ret = OdbcType.Double; break;

            case "real":
            case "smallfloat": ret = OdbcType.Real; break;

            case "serial":
            case "integer":
            case "int": ret = OdbcType.Int; break;

            case "numeric":
            case "numeric precision": ret = OdbcType.Decimal; break;

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

            case "interval": ret = OdbcType.Time; break;

            case "datetime":
            case "timestamp": ret = OdbcType.DateTime; break;

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

            case "nvarchar": ret = OdbcType.NVarChar; break;

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

            case "boolean": ret = OdbcType.Bit; break;

            case "char(36)": ret = OdbcType.UniqueIdentifier; break;
            }
            return(ret);
        }
Exemplo n.º 5
0
 /// <summary>
 /// Convenience method for creating an OdbcParameter with an
 /// appropriate <c>TDbListParameterValue</c> as a value.
 /// </summary>
 public static OdbcParameter OdbcListParameterValue(String name, OdbcType type, IEnumerable value)
 {
     return(new OdbcParameter(name, type)
     {
         Value = new TDbListParameterValue(name, type, value)
     });
 }
Exemplo n.º 6
0
        /// <summary>
        /// Builds an Odbc Parameter object from the arguments.
        /// </summary>
        /// <param name="parameterElement">Parameter definition from the config.</param>
        /// <param name="data">The event notification to pull the parameter's value from.</param>
        /// <returns></returns>
        private static OdbcParameter ParseParameter(ParameterElement parameterElement, EventNotificationData data)
        {
            try
            {
                // Need to convert the string representation of the type to the actual
                // enum OdbcType.
                string[] odbcTypes     = Enum.GetNames(typeof(OdbcType));
                string   odbcTypeMatch = odbcTypes.First(t => t.Equals(parameterElement.DataType, StringComparison.InvariantCultureIgnoreCase));
                OdbcType odbcType      = (OdbcType)Enum.Parse(typeof(OdbcType), odbcTypeMatch);

                // Get property from the data using the property DisplayName (source)
                object value = HttpUtility.HtmlDecode(data.GetValueByDisplayName(parameterElement.Source));

                // Build return object.
                var parameter = new OdbcParameter
                {
                    ParameterName = parameterElement.Name,
                    OdbcType      = odbcType,
                    Size          = parameterElement.LengthAsInt,
                    Value         = value == null ? DBNull.Value : (string)value == string.Empty && odbcType == OdbcType.Int ? 0 : value
                };

                return(parameter);
            }
            catch (Exception ex)
            {
                throw new Exception("Failed to parse parameter.", ex);
            }
        }
Exemplo n.º 7
0
 protected AccessDataProvider_Odbc(string name, MappingSchema mappingSchema) : base(name, mappingSchema)
 {
     if (System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator != ".")
     {
         _decimalType = OdbcType.VarChar;
     }
 }
Exemplo n.º 8
0
 public OdbcParameter(string?name, OdbcType type, int size, string?sourcecolumn) : this()
 {
     ParameterName = name;
     OdbcType      = type;
     Size          = size;
     SourceColumn  = sourcecolumn;
 }
Exemplo n.º 9
0
		public void AddFieldName(string fieldName,OdbcType type)
		{
//			isCallAddFieldName = true ;
			
			ODBCDataField field = new ODBCDataField( fieldName,type ) ;
			
			fieldList.Add(field) ;
		}
Exemplo n.º 10
0
        public void AddFieldName(string fieldName, OdbcType type)
        {
//			isCallAddFieldName = true ;

            ODBCDataField field = new ODBCDataField(fieldName, type);

            fieldList.Add(field);
        }
Exemplo n.º 11
0
        internal void UpdateTypes(SQL_TYPE sqlType)
        {
            SqlType = sqlType;
            OdbcTypeMap map = OdbcTypeConverter.GetTypeMap(SqlType);

            OdbcType = map.OdbcType;
            SqlCType = map.NativeType;
        }
Exemplo n.º 12
0
 public OdbcTypeMap(DbType dbType, OdbcType odbcType,
                    SQL_C_TYPE nativeType, SQL_TYPE sqlType)
 {
     DbType     = dbType;
     OdbcType   = odbcType;
     SqlType    = sqlType;
     NativeType = nativeType;
 }
Exemplo n.º 13
0
 internal OdbcColumn(string Name, OdbcType Type)
 {
     this.ColumnName = Name;
     this.OdbcType   = Type;
     AllowDBNull     = false;
     MaxLength       = 0;
     Digits          = 0;
     Value           = null;
 }
Exemplo n.º 14
0
		internal OdbcColumn(string Name, OdbcType Type)
		{
			this.ColumnName=Name;
			this.OdbcType=Type;		
			AllowDBNull=false;
			MaxLength=0;
			Digits=0;
			Value=null;
		}
Exemplo n.º 15
0
        /*
         * creates where clause for optimistic concurrency
         */
        private string CreateOptWhereClause(OdbcCommand command, int paramCount)
        {
            string [] whereClause = new string [Schema.Rows.Count];

            int partCount = 0;

            foreach (DataRow schemaRow in Schema.Rows)
            {
                // exclude non updatable columns
                if (!IsUpdatable(schemaRow))
                {
                    continue;
                }

                string columnName = GetColumnName(schemaRow);
                if (columnName == String.Empty)
                {
                    throw new InvalidOperationException("Cannot form delete command. Column name is missing!");
                }

                bool     allowNull = schemaRow.IsNull("AllowDBNull") || (bool)schemaRow ["AllowDBNull"];
                OdbcType sqlDbType = schemaRow.IsNull("ProviderType") ? OdbcType.VarChar : (OdbcType)schemaRow ["ProviderType"];
                int      length    = schemaRow.IsNull("ColumnSize") ? -1 : (int)schemaRow ["ColumnSize"];

                if (allowNull)
                {
                    whereClause [partCount++] = String.Format("((? = 1 AND {0} IS NULL) OR ({0} = ?))",
                                                              GetQuotedString(columnName));
                    OdbcParameter nullParam = AddParameter(
                        command,
                        GetParameterName(++paramCount),
                        OdbcType.Int,
                        length,
#if NET_2_0
                        columnName,
#else
                        string.Empty,
#endif
                        DataRowVersion.Original);
                    nullParam.Value = 1;
                    AddParameter(command, GetParameterName(++paramCount),
                                 sqlDbType, length, columnName,
                                 DataRowVersion.Original);
                }
                else
                {
                    whereClause [partCount++] = String.Format("({0} = ?)",
                                                              GetQuotedString(columnName));
                    AddParameter(command, GetParameterName(++paramCount),
                                 sqlDbType, length, columnName,
                                 DataRowVersion.Original);
                }
            }

            return(String.Join(" AND ", whereClause, 0, partCount));
        }
Exemplo n.º 16
0
 public OdbcParameter(string name, OdbcType odbcType, int size,
                      ParameterDirection direction, bool isNullable,
                      byte precision, byte scale, string srcColumn,
                      DataRowVersion srcVersion, object value)
     : this(name, odbcType, size, srcColumn)
 {
     this.Direction     = direction;
     this.IsNullable    = isNullable;
     this.SourceVersion = srcVersion;
 }
Exemplo n.º 17
0
 /// <summary>
 /// 为 OleDbParameter 实例配置属性值。
 /// </summary>
 /// <param name="param">参数。</param>
 /// <param name="name">名称。</param>
 /// <param name="odbcType">数据类型。</param>
 /// <param name="size">数据长度。</param>
 /// <param name="direction">参数类型。</param>
 /// <param name="nullable">表示参数是否可以接受null值。</param>
 /// <param name="sourceColumn">源列的名称。</param>
 /// <param name="sourceVersion">数据行的版本。</param>
 /// <param name="value">参数值。</param>
 public void ConfigureParameter(OdbcParameter param, string name, OdbcType odbcType, int size, ParameterDirection direction, bool nullable, string sourceColumn, DataRowVersion sourceVersion, object value)
 {
     param.OdbcType      = odbcType;
     param.Size          = size;
     param.Value         = value ?? DBNull.Value;
     param.Direction     = direction;
     param.IsNullable    = nullable;
     param.SourceColumn  = sourceColumn;
     param.SourceVersion = sourceVersion;
 }
Exemplo n.º 18
0
        internal static TypeMap FromOdbcType(OdbcType odbcType)
        {
            switch (odbcType)
            {
            case OdbcType.BigInt: return(s_bigInt);

            case OdbcType.Binary: return(s_binary);

            case OdbcType.Bit: return(s_bit);

            case OdbcType.Char: return(_Char);

            case OdbcType.DateTime: return(s_dateTime);

            case OdbcType.Date: return(s_date);

            case OdbcType.Time: return(s_time);

            case OdbcType.Double: return(s_double);

            case OdbcType.Decimal: return(s_decimal);

            case OdbcType.Image: return(_Image);

            case OdbcType.Int: return(s_int);

            case OdbcType.NChar: return(s_NChar);

            case OdbcType.NText: return(_NText);

            case OdbcType.Numeric: return(s_numeric);

            case OdbcType.NVarChar: return(_NVarChar);

            case OdbcType.Real: return(s_real);

            case OdbcType.UniqueIdentifier: return(s_uniqueId);

            case OdbcType.SmallDateTime: return(s_smallDT);

            case OdbcType.SmallInt: return(s_smallInt);

            case OdbcType.Text: return(_Text);

            case OdbcType.Timestamp: return(s_timestamp);

            case OdbcType.TinyInt: return(s_tinyInt);

            case OdbcType.VarBinary: return(s_varBinary);

            case OdbcType.VarChar: return(_VarChar);

            default: throw ODBC.UnknownOdbcType(odbcType);
            }
        }
Exemplo n.º 19
0
        static internal TypeMap FromOdbcType(OdbcType odbcType)
        {
            switch (odbcType)
            {
            case OdbcType.BigInt: return(_BigInt);

            case OdbcType.Binary: return(_Binary);

            case OdbcType.Bit: return(_Bit);

            case OdbcType.Char: return(_Char);

            case OdbcType.DateTime: return(_DateTime);

            case OdbcType.Date: return(_Date);

            case OdbcType.Time: return(_Time);

            case OdbcType.Double: return(_Double);

            case OdbcType.Decimal: return(_Decimal);

            case OdbcType.Image: return(_Image);

            case OdbcType.Int: return(_Int);

            case OdbcType.NChar: return(_NChar);

            case OdbcType.NText: return(_NText);

            case OdbcType.Numeric: return(_Numeric);

            case OdbcType.NVarChar: return(_NVarChar);

            case OdbcType.Real: return(_Real);

            case OdbcType.UniqueIdentifier: return(_UniqueId);

            case OdbcType.SmallDateTime: return(_SmallDT);

            case OdbcType.SmallInt: return(_SmallInt);

            case OdbcType.Text: return(_Text);

            case OdbcType.Timestamp: return(_Timestamp);

            case OdbcType.TinyInt: return(_TinyInt);

            case OdbcType.VarBinary: return(_VarBinary);

            case OdbcType.VarChar: return(_VarChar);

            default: throw ODC.UnknownOdbcType(odbcType);
            }
        }
Exemplo n.º 20
0
        private OdbcCommand CreateInsertCommand(bool option)
        {
            CreateNewCommand(ref _insertCommand);

            string query = String.Format("INSERT INTO {0}", GetQuotedString(TableName));

            string [] columns = new string [Schema.Rows.Count];
            string [] values  = new string [Schema.Rows.Count];

            int count = 0;

            foreach (DataRow schemaRow in Schema.Rows)
            {
                // exclude non updatable columns
                if (!IsUpdatable(schemaRow))
                {
                    continue;
                }

                string columnName = GetColumnName(schemaRow);
                if (columnName == String.Empty)
                {
                    throw new InvalidOperationException("Cannot form insert command. Column name is missing!");
                }

                // create column string & value string
                columns [count]  = GetQuotedString(columnName);
                values [count++] = "?";

                // create parameter and add
                OdbcType sqlDbType = schemaRow.IsNull("ProviderType") ? OdbcType.VarChar : (OdbcType)schemaRow ["ProviderType"];
                int      length    = schemaRow.IsNull("ColumnSize") ? -1 : (int)schemaRow ["ColumnSize"];

                AddParameter(_insertCommand, GetParameterName(count),
                             sqlDbType, length, columnName, DataRowVersion.Current);
            }

            query = String.Format(
#if NET_2_0
                "{0} ({1}) VALUES ({2})",
#else
                "{0}( {1} ) VALUES ( {2} )",
#endif
                query,
#if NET_2_0
                String.Join(", ", columns, 0, count),
                String.Join(", ", values, 0, count));
#else
                String.Join(" , ", columns, 0, count),
                String.Join(" , ", values, 0, count));
#endif
            _insertCommand.CommandText = query;
            return(_insertCommand);
        }
Exemplo n.º 21
0
        public static Dictionary <string, OdbcType> GetsColumnsWithTypes(DataColumnCollection columns)
        {
            Dictionary <string, OdbcType> columnsWithTypes = new Dictionary <string, OdbcType>();

            foreach (DataColumn col in columns)
            {
                OdbcType type = MapCsharpTypeToODBCType(col.DataType);
                columnsWithTypes.Add(col.ColumnName, type);
            }
            return(columnsWithTypes);
        }
Exemplo n.º 22
0
        /// <summary>
        /// 创建一个新的 OleDbParameter 实例。
        /// </summary>
        /// <param name="name">名称。</param>
        /// <param name="odbcType">数据类型。</param>
        /// <param name="size">数据长度。</param>
        /// <param name="direction">参数类型。</param>
        /// <param name="nullable">表示参数是否可以接受null值。</param>
        /// <param name="sourceColumn">源列的名称。</param>
        /// <param name="sourceVersion">数据行的版本。</param>
        /// <param name="value">参数值。</param>
        /// <returns>返回一个新的 OracleParameter 实例。</returns>
        public OdbcParameter CreateParameter(string name, OdbcType odbcType, int size, ParameterDirection direction, bool nullable, string sourceColumn, DataRowVersion sourceVersion, object value)
        {
            OdbcParameter param = CreateParameter(name) as OdbcParameter;

            if (param == null)
            {
                throw new ArgumentNullException("command");
            }
            ConfigureParameter(param, name, odbcType, size, direction, nullable, sourceColumn, sourceVersion, value);
            return(param);
        }
Exemplo n.º 23
0
 private TypeMap(OdbcType odbcType, DbType dbType, Type type, ODBC32.SQL_TYPE sql_type, ODBC32.SQL_C sql_c, ODBC32.SQL_C param_sql_c, int bsize, int csize, bool signType)
 {
     this._odbcType    = odbcType;
     this._dbType      = dbType;
     this._type        = type;
     this._sql_type    = sql_type;
     this._sql_c       = sql_c;
     this._param_sql_c = param_sql_c;
     this._bufferSize  = bsize;
     this._columnSize  = csize;
     this._signType    = signType;
 }
Exemplo n.º 24
0
        private OdbcCommand CreateUpdateCommand(bool option)
        {
            CreateNewCommand(ref _updateCommand);

            string query = String.Format("UPDATE {0} SET", GetQuotedString(TableName));

            string [] setClause = new string [Schema.Rows.Count];

            int count = 0;

            foreach (DataRow schemaRow in Schema.Rows)
            {
                // exclude non updatable columns
                if (!IsUpdatable(schemaRow))
                {
                    continue;
                }

                string columnName = GetColumnName(schemaRow);
                if (columnName == String.Empty)
                {
                    throw new InvalidOperationException("Cannot form update command. Column name is missing!");
                }

                OdbcType sqlDbType = schemaRow.IsNull("ProviderType") ? OdbcType.VarChar : (OdbcType)schemaRow ["ProviderType"];
                int      length    = schemaRow.IsNull("ColumnSize") ? -1 : (int)schemaRow ["ColumnSize"];

                // create column = value string
                setClause [count++] = String.Format("{0} = ?", GetQuotedString(columnName));
                AddParameter(_updateCommand, GetParameterName(count),
                             sqlDbType, length, columnName, DataRowVersion.Current);
            }

            // create where clause. odbc uses positional parameters. so where class
            // is created seperate from the above loop.
            string whereClause = CreateOptWhereClause(_updateCommand, count);

            query = String.Format(
#if NET_2_0
                "{0} {1} WHERE ({2})",
#else
                "{0} {1} WHERE ( {2} )",
#endif
                query,
#if NET_2_0
                String.Join(", ", setClause, 0, count),
#else
                String.Join(" , ", setClause, 0, count),
#endif
                whereClause);
            _updateCommand.CommandText = query;
            return(_updateCommand);
        }
 private TypeMap(OdbcType odbcType, DbType dbType, Type type, ODBC32.SQL_TYPE sql_type, ODBC32.SQL_C sql_c, ODBC32.SQL_C param_sql_c, int bsize, int csize, bool signType)
 {
     this._odbcType = odbcType;
     this._dbType = dbType;
     this._type = type;
     this._sql_type = sql_type;
     this._sql_c = sql_c;
     this._param_sql_c = param_sql_c;
     this._bufferSize = bsize;
     this._columnSize = csize;
     this._signType = signType;
 }
Exemplo n.º 26
0
        /*
         * creates where clause for optimistic concurrency
         */
        private string CreateOptWhereClause(OdbcCommand command, bool option)
        {
            string [] whereClause = new string [Schema.Rows.Count];

            int count = 0;

            foreach (DataRow schemaRow in Schema.Rows)
            {
                // exclude non updatable columns
                if (!IsUpdatable(schemaRow))
                {
                    continue;
                }

                string columnName = null;
                if (option)
                {
                    columnName = GetColumnName(schemaRow);
                }
                else
                {
                    columnName = String.Format("@p{0}", count);
                }

                if (columnName == String.Empty)
                {
                    throw new InvalidOperationException("Cannot form delete command. Column name is missing!");
                }

                bool     allowNull = schemaRow.IsNull("AllowDBNull") || (bool)schemaRow ["AllowDBNull"];
                OdbcType sqlDbType = schemaRow.IsNull("ProviderType") ? OdbcType.VarChar : (OdbcType)schemaRow ["ProviderType"];
                int      length    = schemaRow.IsNull("ColumnSize") ? -1 : (int)schemaRow ["ColumnSize"];

                if (allowNull)
                {
                    whereClause [count] = String.Format("((? = 1 AND {0} IS NULL) OR ({0} = ?))",
                                                        columnName);
                    AddParameter(command, columnName, sqlDbType, length, columnName, DataRowVersion.Original);
                    AddParameter(command, columnName, sqlDbType, length, columnName, DataRowVersion.Original);
                }
                else
                {
                    whereClause [count] = String.Format("({0} = ?)", columnName);
                    AddParameter(command, columnName, sqlDbType, length, columnName, DataRowVersion.Original);
                }

                count++;
            }

            return(String.Join(" AND ", whereClause, 0, count));
        }
Exemplo n.º 27
0
        internal readonly bool _signType;   // this type may be has signature information

        private TypeMap(OdbcType odbcType, DbType dbType, Type type, ODBC32.SQL_TYPE sql_type, ODBC32.SQL_C sql_c, ODBC32.SQL_C param_sql_c, int bsize, int csize, bool signType)
        {
            _odbcType = odbcType;
            _dbType   = dbType;
            _type     = type;

            _sql_type    = sql_type;
            _sql_c       = sql_c;
            _param_sql_c = param_sql_c; // alternative sql_c type for parameters

            _bufferSize = bsize;
            _columnSize = csize;
            _signType   = signType;
        }
Exemplo n.º 28
0
        private OdbcParameter AddParameter(OdbcCommand cmd, string paramName, OdbcType odbcType,
                                           int length, string sourceColumnName, DataRowVersion rowVersion)
        {
            OdbcParameter param;

            if (length >= 0 && sourceColumnName != String.Empty)
            {
                param = cmd.Parameters.Add(paramName, odbcType, length, sourceColumnName);
            }
            else
            {
                param = cmd.Parameters.Add(paramName, odbcType);
            }
            param.SourceVersion = rowVersion;
            return(param);
        }
Exemplo n.º 29
0
        public static OdbcType MapCsharpTypeToODBCType(Type dataType)
        {
            OdbcType OdbcDbType = OdbcType.BigInt;

            if (dataType == Type.GetType("System.Int32"))
            {
                OdbcDbType = OdbcType.BigInt;
            }
            else if (dataType == Type.GetType("System.String"))
            {
                OdbcDbType = OdbcType.Text;
            }
            else if (dataType == Type.GetType("System.Boolean"))
            {
                OdbcDbType = OdbcType.Bit;
            }
            else if (dataType == Type.GetType("System.TimeSpan"))
            {
                OdbcDbType = OdbcType.Time;
            }
            else if (dataType == Type.GetType("System.Int16"))
            {
                OdbcDbType = OdbcType.Int;
            }
            else if (dataType == Type.GetType("System.Double"))
            {
                OdbcDbType = OdbcType.Double;
            }
            else if (dataType == Type.GetType("System.Char"))
            {
                OdbcDbType = OdbcType.VarChar;
            }
            else if (dataType == Type.GetType("System.DateTime"))
            {
                OdbcDbType = OdbcType.DateTime;
            }
            else if (dataType == Type.GetType("System.Decimal"))
            {
                OdbcDbType = OdbcType.Decimal;
            }
            else if (dataType == Type.GetType("System.Byte[]"))
            {
                OdbcDbType = OdbcType.VarBinary;
            }
            return(OdbcDbType);
        }
Exemplo n.º 30
0
 [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]   // MDAC 69508
 public OdbcParameter(string parameterName,
                      OdbcType odbcType, int size,
                      ParameterDirection parameterDirection, Boolean isNullable,
                      Byte precision, Byte scale,
                      string srcColumn, DataRowVersion srcVersion,
                      object value)
 {
     this.ParameterName = parameterName;
     this.OdbcType      = odbcType;
     this.Size          = size;
     this.Direction     = parameterDirection;
     this.IsNullable    = isNullable;
     this.Precision     = precision;
     this.Scale         = scale;
     this.SourceColumn  = srcColumn;
     this.SourceVersion = srcVersion;
     this.Value         = value;
 }
Exemplo n.º 31
0
 [EditorBrowsableAttribute(EditorBrowsableState.Advanced)] // MDAC 69508
 public OdbcParameter(string?parameterName,
                      OdbcType odbcType, int size,
                      ParameterDirection parameterDirection,
                      byte precision, byte scale,
                      string?sourceColumn, DataRowVersion sourceVersion, bool sourceColumnNullMapping,
                      object?value) : this()
 { // V2.0 everything - round trip all browsable properties + precision/scale
     this.ParameterName           = parameterName;
     this.OdbcType                = odbcType;
     this.Size                    = size;
     this.Direction               = parameterDirection;
     this.PrecisionInternal       = precision;
     this.ScaleInternal           = scale;
     this.SourceColumn            = sourceColumn;
     this.SourceVersion           = sourceVersion;
     this.SourceColumnNullMapping = sourceColumnNullMapping;
     this.Value                   = value;
 }
Exemplo n.º 32
0
        public static OdbcType GetOdbcParameterType(DbType type)
        {
            OdbcType result = OdbcType.Int;

            switch (type)
            {
            case DbType.DateTime:
                result = OdbcType.DateTime;
                break;

            case DbType.Date:
                result = OdbcType.DateTime;
                break;

            case DbType.Decimal:
                result = OdbcType.Decimal;
                break;

            case DbType.Double:
                result = OdbcType.Double;
                break;

            case DbType.Single:
                result = OdbcType.Double;
                break;

            case DbType.Int32:
                result = OdbcType.Int;
                break;

            case DbType.Int64:
                result = OdbcType.BigInt;
                break;

            case DbType.Object:
                result = OdbcType.Image;
                break;

            case DbType.String:
                result = OdbcType.NVarChar;
                break;
            }
            return(result);
        }
Exemplo n.º 33
0
        ///
        /// 构造一个OdbcParameter参数值
        ///
        /// 参数名
        /// 参数类型
        /// 参数类型大小
        /// 输入/输出
        /// 参数值
        /// 返回一个OdbcParameter参数
        public static OdbcParameter MakeParam(string ParamName, OdbcType DbType, Int32 Size, ParameterDirection Direction, object Value)
        {
            OdbcParameter param;

            if (Size > 0)
            {
                param = new OdbcParameter(ParamName, DbType, Size);
            }
            else
            {
                param = new OdbcParameter(ParamName, DbType);
            }
            param.Direction = Direction;
            if (!(Direction == ParameterDirection.Output && Value == null))
            {
                param.Value = Value;
            }
            return(param);
        }
Exemplo n.º 34
0
		public OdbcParameter (string name, OdbcType type, int size, string sourcecolumn)
			: this (name, type, size)
		{
			this.SourceColumn = sourcecolumn;
		}
Exemplo n.º 35
0
		public OdbcParameter (string name, OdbcType type, int size)
			: this (name, type)
		{
			this.Size = size;
		}
 public TypeMap (OdbcType odbcType, SQL_C_TYPE sqlCType, SQL_TYPE sqlType, short defaultFlags)
         : this (odbcType, sqlCType, sqlType)
 {
         BitMask = defaultFlags;
 }
Exemplo n.º 37
0
 public OdbcParameter(string name, OdbcType type, int size) : this() {
     ParameterName  = name;
     OdbcType       = type;
     Size           = size;
 }
 public OdbcParameter Add(string parameterName, OdbcType odbcType, int size)
 {
     return this.Add(new OdbcParameter(parameterName, odbcType, size));
 }
Exemplo n.º 39
0
		public static DbType Parse(OdbcType dbType)
		{
			return DbTypeMap.Reverse(dbType);
		}
Exemplo n.º 40
0
		public OdbcParameter Add (string parameterName, OdbcType odbcType)
		{
			return Add (new OdbcParameter (parameterName, odbcType));
		}
Exemplo n.º 41
0
        internal readonly bool _signType;   // this type may be has signature information

        private TypeMap(OdbcType odbcType, DbType dbType, Type type, ODBC32.SQL_TYPE sql_type, ODBC32.SQL_C sql_c, ODBC32.SQL_C param_sql_c, int bsize, int csize, bool signType) {
            _odbcType = odbcType;
            _dbType = dbType;
            _type = type;

            _sql_type = sql_type;
            _sql_c = sql_c;
            _param_sql_c = param_sql_c; // alternative sql_c type for parameters

            _bufferSize = bsize;
            _columnSize = csize;
            _signType = signType;
        }
 public TypeMap (OdbcType odbcType, SQL_C_TYPE sqlCType, SQL_TYPE sqlType)
 {
         OdbcType        = odbcType;
         SqlType         = sqlType;
         SqlCType        = sqlCType;
         BitMask         = DefaultForOdbcType 
                 | DefaultForSQLCType
                 | DefaultForSQLType
                 ;
 }
Exemplo n.º 43
0
		private OdbcParameter AddParameter (OdbcCommand cmd, string paramName, OdbcType odbcType,
						    int length, string sourceColumnName, DataRowVersion rowVersion)
		{
			OdbcParameter param;
			if (length >= 0 && sourceColumnName != String.Empty)
				param = cmd.Parameters.Add (paramName, odbcType, length, sourceColumnName);
			else
				param = cmd.Parameters.Add (paramName, odbcType);
			param.SourceVersion = rowVersion;
			return param;
		}
 public static SQL_TYPE ConvertToSqlType (OdbcType type)
 {
         return OdbcTypeMap [type].SqlType;
 }
 public int IndexOf (OdbcType odbcType)
 {
         for (int i=0; i < List.Count; i++) {
                 TypeMap map = (TypeMap) List [i];
                 if (map.OdbcType == odbcType
                     && (map.BitMask & TypeMap.DefaultForOdbcType) > 0 )
                         return i;
         }
         return -1;
 }
 public TypeMap this [OdbcType odbcType]
 {
         get {
                 foreach (TypeMap map in List){
                         if (map.OdbcType == odbcType
                             && (map.BitMask & TypeMap.DefaultForOdbcType) > 0 )
                                 return map;
                 }
                 throw new ArgumentException (String.Format ("Type mapping for odbc type {0} is not found", 
                                                             odbcType.ToString ()
                                                             )
                                              );
         }
         set {
                 int i = IndexOf (odbcType);
                 if (i == -1)
                         Add (value);
                 List [i] = value;
         }
 }
Exemplo n.º 47
0
		private string GetFiledTypeString(OdbcType type)
		{
			string val = "" ;
			switch ( type )
			{
				case OdbcType.Int :
				case OdbcType.SmallInt :
				{
					val = " integer " ;
				}
				break;
				
				case OdbcType.Real:
				{
					val = " REAL " ;
				}
				break;
				
				case OdbcType.Text :
				case OdbcType.NText :
				case OdbcType.VarChar :
				case OdbcType.NVarChar :
				{
					val = " VARCHAR (255) " ;
				}
				break;
				
				default :
				{
					val = " integer " ;
				}
				break ;
			}
			
			return val ;
		}
Exemplo n.º 48
0
 [ EditorBrowsableAttribute(EditorBrowsableState.Advanced) ] // MDAC 69508
 public OdbcParameter(string parameterName,
                      OdbcType odbcType,
                      int size,
                      ParameterDirection parameterDirection,
                      Boolean isNullable,
                      Byte precision,
                      Byte scale,
                      string srcColumn,
                      DataRowVersion srcVersion,
                      object value
                      ) : this() { // V1.0 everything
     this.ParameterName = parameterName;
     this.OdbcType = odbcType;
     this.Size = size;
     this.Direction = parameterDirection;
     this.IsNullable = isNullable;
     PrecisionInternal = precision;
     ScaleInternal = scale;
     this.SourceColumn = srcColumn;
     this.SourceVersion = srcVersion;
     this.Value = value;
 }
Exemplo n.º 49
0
 static internal Exception UnknownOdbcType(OdbcType odbctype) {
     return ADP.InvalidEnumerationValue(typeof(OdbcType), (int) odbctype);
 }
		public OdbcParameter Add (string name, OdbcType type,
					   int width, string src_col)
		{
			return Add (new OdbcParameter (name, type, width, src_col));
		}
Exemplo n.º 51
0
 static internal TypeMap FromOdbcType(OdbcType odbcType) {
     switch(odbcType) {
     case OdbcType.BigInt: return _BigInt;
     case OdbcType.Binary: return _Binary;
     case OdbcType.Bit: return _Bit;
     case OdbcType.Char: return _Char;
     case OdbcType.DateTime: return _DateTime;
     case OdbcType.Date: return _Date;
     case OdbcType.Time: return _Time;
     case OdbcType.Double: return _Double;
     case OdbcType.Decimal: return _Decimal;
     case OdbcType.Image: return _Image;
     case OdbcType.Int: return _Int;
     case OdbcType.NChar: return _NChar;
     case OdbcType.NText: return _NText;
     case OdbcType.Numeric: return _Numeric;
     case OdbcType.NVarChar: return _NVarChar;
     case OdbcType.Real: return _Real;
     case OdbcType.UniqueIdentifier: return _UniqueId;
     case OdbcType.SmallDateTime: return _SmallDT;
     case OdbcType.SmallInt: return _SmallInt;
     case OdbcType.Text: return _Text;
     case OdbcType.Timestamp: return _Timestamp;
     case OdbcType.TinyInt: return _TinyInt;
     case OdbcType.VarBinary: return _VarBinary;
     case OdbcType.VarChar: return _VarChar;
     default: throw ODBC.UnknownOdbcType(odbcType);
     }
 }
Exemplo n.º 52
0
		public OdbcParameter (string name, OdbcType type)
			: this ()
		{
			this.ParameterName = name;
			_typeMap = (OdbcTypeMap) OdbcTypeConverter.GetTypeMap (type);
		}
 public OdbcParameter Add(string parameterName, OdbcType odbcType, int size, string sourceColumn)
 {
     return this.Add(new OdbcParameter(parameterName, odbcType, size, sourceColumn));
 }
Exemplo n.º 54
0
		public OdbcParameter (string name, OdbcType dataType, int size, string srcColumn)
			: this (name, dataType, size)
		{
			this.SourceColumn = srcColumn;
		}
		public OdbcParameter Add (string name, OdbcType type)
	        {
			return Add (new OdbcParameter (name, type));
		}
Exemplo n.º 56
0
 public OdbcParameter(string name, OdbcType type, int size, string sourcecolumn) : this() {
     ParameterName  = name;
     OdbcType       = type;
     Size           = size;
     SourceColumn   = sourcecolumn;
 }
Exemplo n.º 57
0
		public OdbcParameter(string name, OdbcType dataType, int size, ParameterDirection direction, bool isNullable, byte precision, byte scale, string srcColumn, DataRowVersion srcVersion, object value)
			: this (name, dataType, size, srcColumn)
		{
			this.Direction = direction;
			this.IsNullable = isNullable;
			this.Precision = precision;
			this.Scale = scale;
			this.SourceVersion = srcVersion;
			this.Value = value;
		}
Exemplo n.º 58
0
		public OdbcParameter (string parameterName, OdbcType odbcType, int size,
				     ParameterDirection parameterDirection, bool isNullable, 
				     byte precision, byte scale, string srcColumn, 
				     DataRowVersion srcVersion, object value)
			: this (parameterName, odbcType, size, srcColumn)
		{
			this.Direction = parameterDirection;
			this.IsNullable = isNullable;
			this.SourceVersion = srcVersion;
		}
Exemplo n.º 59
0
 public OdbcParameter(string name, OdbcType type) : this() {
     ParameterName  = name;
     OdbcType       = type;
 }
Exemplo n.º 60
0
 [ EditorBrowsableAttribute(EditorBrowsableState.Advanced) ] // MDAC 69508
 public OdbcParameter(string parameterName,
                          OdbcType odbcType, int size,
                          ParameterDirection parameterDirection,
                          Byte precision, Byte scale,
                          string sourceColumn, DataRowVersion sourceVersion, bool sourceColumnNullMapping,
                          object value) : this() { // V2.0 everything - round trip all browsable properties + precision/scale
     this.ParameterName = parameterName;
     this.OdbcType = odbcType;
     this.Size = size;
     this.Direction = parameterDirection;
     this.PrecisionInternal = precision;
     this.ScaleInternal = scale;
     this.SourceColumn = sourceColumn;
     this.SourceVersion = sourceVersion;
     this.SourceColumnNullMapping = sourceColumnNullMapping;
     this.Value = value;
 }