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); }
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; }
protected override int GetProviderType(int jdbcType) { return((int)OleDbConvert.JdbcTypeToOleDbType(jdbcType)); }