System.Data.SqlClient.SqlConvert.JdbcTypeToSqlDbType C# (CSharp) Method

JdbcTypeToSqlDbType() static private method

static private JdbcTypeToSqlDbType ( int jdbcType ) : SqlDbType
jdbcType int
return SqlDbType
		internal static SqlDbType JdbcTypeToSqlDbType(int jdbcType)
		{
			// FIXME : other java.sql.Type
			// Types.ARRAY
			if(Types.BIGINT == jdbcType) return SqlDbType.BigInt;
			if(Types.BINARY == jdbcType) return SqlDbType.Binary;
			if(Types.BIT == jdbcType) return SqlDbType.Bit;
			if(Types.BLOB == jdbcType) return SqlDbType.Binary;
			// Types.BOOLEAN
			if(Types.CHAR == jdbcType) return SqlDbType.Char;
			if(Types.CLOB == jdbcType) return SqlDbType.Binary;
			if(Types.DATE == jdbcType) return SqlDbType.DateTime;
			if(Types.DECIMAL == jdbcType) return SqlDbType.Decimal;
			// Types.DISTINCT
			if(Types.DOUBLE == jdbcType) return SqlDbType.Float;
			if(Types.FLOAT == jdbcType) return SqlDbType.Float;
			if(Types.INTEGER == jdbcType) return SqlDbType.Int;
			// Types.JAVA_OBJECT
			if(Types.LONGVARBINARY == jdbcType) return SqlDbType.Image;
			if(Types.LONGVARCHAR == jdbcType) return SqlDbType.Text;
			// Types.NULL
			if(Types.NUMERIC == jdbcType) return SqlDbType.Decimal;
			if(Types.REAL == jdbcType) return SqlDbType.Real;
			// Types.REF
			if(Types.SMALLINT == jdbcType) return SqlDbType.SmallInt;
			// Types.STRUCT
			if(Types.TIME == jdbcType) return SqlDbType.DateTime;
			if(Types.TIMESTAMP == jdbcType) return SqlDbType.DateTime;
			if(Types.TINYINT == jdbcType) return SqlDbType.TinyInt;
			if(Types.VARBINARY == jdbcType) return SqlDbType.VarBinary;
			if(Types.VARCHAR == jdbcType) return SqlDbType.NVarChar;
			return SqlDbType.Variant;
		}

Usage Example

        protected internal sealed override void SetParameterDbType(ResultSet res)
        {
            int dataType = res.getInt("DATA_TYPE");

            SqlDbType = SqlConvert.JdbcTypeToSqlDbType(dataType);
            JdbcType  = dataType;
        }
All Usage Examples Of System.Data.SqlClient.SqlConvert::JdbcTypeToSqlDbType