Data Types
- Last Updated: April 16, 2026
- 6 minute read
- ADO.NET
- Documentation
The following tables list the use of data types supported by the DB2 data provider:
- Mapping DB2 Data Types When No IANA Code Page Is Defined maps the DB2 data types to the .NET Framework types when no IANA code page is defined.
- Mapping Data Types When a Column Is Defined as Character Set 65535 and No IANA Code Page is Defined maps the data types the data provider uses when a column is defined as character set 65535 and no IANA code page is defined.
- Mapping Data Types When a Column Is Defined as Character Set 65535 and an IANA Code Page Is Defined maps the data types the data provider uses when a column is defined as character set 65535 and an IANA code page is defined.
- Mapping System.Data.DbTypes to DB2DbType Enumerations maps the data types the data provider uses if only the System.Data.DbType is specified.
- Mapping .NET Framework Data Types to DB2DbTypes shows the mapping that the data provider uses to infer a data type if the provider-specific type and the System.Data.DbType are not provided.
- Data Types Supported With Stream Objects shows the mapping that the data provider supports for the use of streams as inputs to Long data parameters.
Mapping DB2 Data Types to .NET Framework Data Types
The following table maps the DB2 data types to the .NET Framework types when no IANA code page is defined. You can use the table to infer the data types that are used when a DataSet is filled using a DataAdapter. This table also identifies the accessors to use for accessing the data when a DataReader object is used directly.
In this table, the columns are defined as follows:
- The DB2 Data Type column refers to the native type name.
- The DB2DbType column refers to the DB2 data provider’s type enumeration. Generally, there is a one-to-one mapping between the native type and the DB2DbType.
- The .NET Framework Type column refers to the base data types available in the Framework.
- The .NET Framework Typed Accessor column refers to the method that must be used to access a column of this type when using a DataReader.
Mapping DB2 Data Types When No IANA Code Page Is Defined
| DB2 Data Type | DB2DbType | .NET Framework Type | .NET Framework Typed Accessor |
| BIGINT | BigInt | Int64 | GetInt64() |
| BINARY | Binary | Byte[] | GetBytes() |
| BLOB1 | Blob | Byte[] | GetBytes() |
| CHAR | Char | String[] Char[] |
GetString() GetChars() |
| CHAR FOR BIT DATA | Binary | Byte[] | GetBytes() |
| CLOB2 | Clob | String[] Char[] |
GetString() GetChars() |
| DATALINK3 | Datalink | String[] Char[] |
GetString() GetChars() |
| DATE | Date | DateTime | GetDateTime() |
| DBCLOB | DBClob | String[] Char[] |
GetString() GetChars() |
| DECFLOAT | DecimalFloat4 | Double | GetDouble GetDecimal |
| DECIMAL | Decimal | Decimal | GetDecimal() |
| DOUBLE | Double | Double | GetDouble() |
| FLOAT | Double | Double | GetDouble() |
| GRAPHIC | Graphic | String[] Char[] |
GetString() GetChars() |
| INTEGER | Integer | Int32 | GetInt32() |
| LONG VARCHAR | LongVarChar | String[] Char[] |
GetString() GetChars() |
| LONG VARCHAR FOR BIT DATA | LongVarBinary | Byte[] | GetBytes() |
| LONG VARGRAPHIC | LongVarGraphic | String[] Char[] |
GetString() GetChars() |
| NUMERIC | Decimal | Decimal | GetDecimal() |
| REAL | Real | Single | GetFloat() |
| ROWID5 | RowId | Byte[] | GetBytes() |
| SMALLINT | Smallint | Int16 | GetInt16() |
| TIME | Time | TimeSpan | GetValue() |
| TIMESTAMP | Timestamp | DateTime | GetDateTime() |
| VARBINARY | VarBinary | Byte[] | GetBytes() |
| VARCHAR | String Char |
String[] Char[] |
GetString() GetChars() |
| VARCHAR FOR BIT DATA | VarBinary | Byte[] | GetBytes() |
| VARGRAPHIC | Graphic | String[] Char[] |
GetString() GetChars() |
| XML6 | Xml | String[] Byte[] |
GetChars() GetString() GetValue() GetValues() GetXmlReader()7 |
1 Retrieving and updating Blobs is supported by the DB2 data provider only with DB2 v8.1 or higher for Linux/UNIX/Windows, and DB2 for z/OS, and DB2 V5R2 and higher for iSeries.
2 On DB2 v7.1 and v8.1 for Linux/UNIX/Windows and DB2 V5R2 FOR i, only the first 32 KB of the Clob data type is returned when fetching, and only 32 KB can be inserted and updated.
3 Not supported with DB2 for z/OS and DB2 for i.
4 You can fetch or insert DecimalFloat values as Double, Decimal, or String. Fetching as Double or Decimal may result in rounding. Using String allows you to fetch or insert unrounded values.
5 Only supported for DB2 for z/OS.
6 Only supported for DB2 V9.1 for Linux/UNIX/Windows and higher.
7 For information on this overloaded method, see GetXmlReader in the online help.
As shown in following Table, when the Charset For 65535 connection string option is set to the default value, an empty string, and the column is defined with a character set of 65535, the data provider uses different data types to return character data.
Mapping Data Types When a Column Is Defined as Character Set 65535 and No IANA Code Page is Defined
| DB2 Type | DB2DbType | .NET Framework Type | .NET Framework Typed Accessor |
| CHAR | Binary | Byte[] | GetBytes() |
| CHAR FOR BIT DATA | Binary | Byte[] | GetBytes() |
| LONG VARCHAR | LongVarBinary | Byte[] | GetBytes() |
| LONG VARCHAR FOR BIT DATA | LongVarBinary | Byte[] | GetBytes() |
| VARCHAR | VarBinary | Byte[] | GetBytes() |
| VARCHAR FOR BIT DATA | VarBinary | Byte[] | GetBytes() |
When the Charset For 65535 connection string option is set to a valid IANA code page name and the column is defined with a character set of 65535, the data provider uses different data types to return character data, as shown in following table. Columns defined as Char For Bit Data, Varchar For Bit Data, and Longvarchar For Bit Data are by definition created with a character set of 65535.
Mapping Data Types When a Column Is Defined as Character Set 65535 and an IANA Code Page Is Defined
| DB2 Type | DB2DbType | .NET Framework Type | .NET Framework Typed Accessor |
| CHAR | Char | Char | String Char[] |
| CHAR FOR BIT DATA | Char | Char | GetString GetChar[] |
| LONG VARCHAR | LongVarChar | String Char[] |
GetString() GetChars() |
| LONG VARCHAR FOR BIT DATA | LongVarChar | String Chars[] |
GetString() GetChars() |
| VARCHAR | VarChar | String Char[] |
GetString() GetChars() |
| VARCHAR FOR BIT DATA | VarChar | String Char[] |
GetString() GetChars() |
Mapping Parameter Data Types
The type of the parameter is specific to each DataDirect Connect for ADO.NET data provider. The DB2 data provider must convert the parameter value to a native format before sending it to the server. The best way for an application to describe a parameter is to use the provider-specific type enumeration. In generic programming circumstances, the provider-specific type may not be available. In this situation, the data type must be inferred from either the System.Data.DbType or from the .NET Framework type of the parameter’s value.
The DB2 data provider uses the following order when inferring the data type of a parameter:
- The data provider uses the provider-specific data type if it has been specified.
- The data provider infers the data type from the System.Data.DbType if it has been specified, but the data provider-specific type has not been specified.
- The data provider infers the data type from the .NET Framework type if the provider-specific type and the System.Data.DbType have not been specified.
The following table shows the mapping that is used if only the System.Data.DbType is specified.
Mapping System.Data.DbTypes to DB2DbType Enumerations
| System.Data.DbType | DB2DbType Enumeration |
| AnsiString | Clob, DataLink, LongVarChar |
| AnsiString | VarChar or Clob
|
| AnsiStringFixedLength | Char or VarChar3 |
| Binary | Binary, Blob, LongVarBinary, LongVarBinary |
| Binary | VarBinary or Blob4,5 |
| Byte | Binary |
| Date | Date |
| DateTime | TimeStamp |
| Decimal | Decimal, DecimalFloat |
| Double | DecimalFloat, Double |
| Int16 | SmallInt |
| Int32 | Integer |
| Int64 | BigInt |
| Single | Real |
| String | DbClob |
| String | LongVarGraphic |
| String | VarChar or Clob1 |
| String | VarChar or Clob1 Xml6 |
| String | VarGraphic |
| StringFixedLength | Graphic |
| StringFixedLength | VarChar or Char3 |
| Time | Time |
| Xml | Xml7 |
1 Depends on the size. If the length is greater than 32 KB, the type must be Clob.
2 Clobs with length of greater than 32 KB are not supported for DB2 v7.x for Linux/UNIX/Windows.
3 Depends on the size. If the length is greater than 254 bytes, the type must be VarChar.
4 Depends on the size. If the length is greater than 32 KB, the type must be Blob.
5 Blobs are supported only for DB2 v8.1 and higher for Linux/UNIX/Windows and DB2 for z/OS, and DB2 for i5/OS V5R4 and higher.
6 If the Xml Describe Type connection string option is set to string.
7 If the Xml Describe Type connection string option is set to binary.
The following table shows the mapping that the data provider uses to infer a data type if the provider-specific type and the System.Data.DbType are not provided.
Mapping .NET Framework Data Types to DB2DbTypes
| .NET Framework Type | DB2DbType |
| Boolean | SmallInt |
| Byte | SmallInt |
| Byte[] | VarBinary or Blob1 |
| Char | Not supported |
| DateTime | Timestamp |
| Decimal | Decimal |
| Double | Double or Decfloat |
| GUID | Not supported |
| Int16 | SmallInt |
| Int32 | Integer |
| Int64 | BigInt |
| Object | Not supported |
| Single | Real |
| String | VarChar or Clob2 |
| Uint16 | Integer |
| Uint32 | Decimal |
| Uint64 | Decimal |
1 Depends on the size. If the length is greater than 32 KB, the type must be a Blob.
2 Depends on the size. If the length is greater than 32 KB, the type must be a Clob.
Data Types Supported With Stream Objects
The DB2 data provider supports the use of streams as inputs to Long data parameters with the data types listed in the following table.
Data Types Supported With Stream Objects
| DB2 Data Type | Stream Type Supported |
| Blob | Stream |
| Clob | TextReader |
| Dbclob | TextReader |
| Xml | Stream |
See Using Streams as Input to Long Data Parameters for more information about using streams.