예제 #1
0
        protected internal sealed override void SetParameterDbType(ResultSet res)
        {
            int jdbcType = res.getInt("DATA_TYPE");

            // FIXME : is that correct?
            if (jdbcType == Types.OTHER)
            {
                string typeName = res.getString("TYPE_NAME");
                if (String.Compare("BLOB", typeName, true, CultureInfo.InvariantCulture) == 0)
                {
                    jdbcType = Types.BLOB;
                }
                else if (String.Compare("CLOB", typeName, true, CultureInfo.InvariantCulture) == 0)
                {
                    jdbcType = Types.CLOB;
                }
                else if (String.Compare("FLOAT", typeName, true, CultureInfo.InvariantCulture) == 0)
                {
                    jdbcType = Types.FLOAT;
                }
                else if (String.Compare("NVARCHAR2", typeName, true, CultureInfo.InvariantCulture) == 0)
                {
                    jdbcType = Types.VARCHAR;
                }
                else if (String.Compare("NCHAR", typeName, true, CultureInfo.InvariantCulture) == 0)
                {
                    jdbcType = Types.VARCHAR;
                }
            }
            OleDbType = OleDbConvert.JdbcTypeToOleDbType(jdbcType);
            JdbcType  = jdbcType;
        }
예제 #2
0
        protected internal sealed override object ConvertValue(object value)
        {
            // can not convert null or DbNull to other types
            if (value == null || value == DBNull.Value)
            {
                return(value);
            }

            // FIXME : some other way to do this?
            if (OleDbType == OleDbType.Binary)
            {
                return(value);
            }
            // .NET throws an exception to the user.
            object convertedValue = value;

            // note : if we set user parameter jdbc type inside prepare interbal, the db type is not set
            if (value is IConvertible && (IsDbTypeSet || IsJdbcTypeSet))
            {
                OleDbType oleDbType = (IsDbTypeSet) ? OleDbType : OleDbConvert.JdbcTypeToOleDbType((int)JdbcType);
                Type      to        = OleDbConvert.OleDbTypeToValueType(oleDbType);
                if (!(value is DateTime && to == DbTypes.TypeOfTimespan)) //anyway will go by jdbc type
                {
                    convertedValue = Convert.ChangeType(value, to);
                }
            }
            return(convertedValue);
        }
예제 #3
0
        public override String GetDataTypeName(int columnIndex)
        {
            try {
                string jdbcTypeName = Results.getMetaData().getColumnTypeName(columnIndex + 1);

                return(OleDbConvert.JdbcTypeNameToDbTypeName(jdbcTypeName));
            }
            catch (SQLException e) {
                throw CreateException(e);
            }
        }
예제 #4
0
 protected internal sealed override int JdbcTypeFromProviderType()
 {
     return(OleDbConvert.OleDbTypeToJdbcType(OleDbType));
 }
 protected override int GetProviderType(int jdbcType)
 {
     return((int)OleDbConvert.JdbcTypeToOleDbType(jdbcType));
 }