Assembly: System.Data (in system.data.dll)
/** @property */ public Type get_DataType () /** @property */ public void set_DataType (Type value)
Property ValueA Type object that represents the column data type.
Setting the DataType value is very important to guaranteeing the correct creation and updating of data in a data source.
The DataType property supports the following base .NET Framework data types:
as well as the following array type:
An exception is generated when changing this property after the column has begun storing data.
If AutoIncrement is set to true before setting the DataType property, and you try to set the type to anything except an integer type, an exception is generated.
A column of data type Byte requires special treatment in certain cases since, unlike the base .NET Framework data types, it is a reference data type. If a column of data type Byte is used as a PrimaryKey, or as a Sort or RowFilter key for a DataView, any change to the column value must involve assigning the Byte column value to a separately instantiated Byte object. This assignment is required to trigger the update of the internal indexes used by sorting, filtering, and primary key operations. This is illustrated by the following example:
byte columnValue = (byte)myDataTable.Rows; byte newValue = (byte)columnValue.Clone(); newValue = 2; myDataTable.Rows = newValue;
Although it is possible to define a column as data type other than the base .NET Framework data types and Byte, such a column will be treated as a user-defined type, subject to the following usage restrictions. (For more information on user-defined types, see Creating and Using User-Defined Types.)
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.